55 posts
Posted 10 April 2013 - 03:52 AM
Hi everyone =)
in a first time:
- I'm french and my english isn't perfect, i hope you will under stand what i'm doing and my question ^^
- I totally forgot from where i took this part of program, as i hate to copy without tell from where i take the code, if you recognize the code, tell me, i'll put the source ;)/> (only thing i remember: i took it from a startup/instal of an OS …)
So, here we go:
i'm doing a multiple part programs (as an OS), but i want that all parts "installed" when you run the startup (still as an OS). So i looked many codes and found:
root = "http://pastebin.com/raw.php?i=18bq095q/"
file = "startup"
local response = http.get(root..file)
if response then
while response do
local sResponse = response.readAll()
response.close()
cache = shell.resolve( file )
local file = fs.open( cache, "w" )
file.write( sResponse )
file.close()
response = nil
end
end
os.reboot()
But i'm always copying the
pastebin's page source code …
How can i fix that? =/
199 posts
Location
Switzerland
Posted 10 April 2013 - 05:10 AM
why you not just do this
then inside the startup file you can do the same for all the oder files
root = "18bq095q"
file = "startup"
pastebin get root file
then you could add a table with all the pastebin codes and the relevant name and run a loop like
local myprograms = {"editor", "whatever", "idontknow"}
local mypastebins = {"18bq095q", "13n083q", "12345"}
for i = 1,myprograms do
pastebin get myprograms[i] mypastebins[i]
end
just as example
55 posts
Posted 10 April 2013 - 05:46 AM
why you not just do this
then inside the startup file you can do the same for all the oder files
root = "18bq095q"
file = "startup"
pastebin get root file
bios:338: [string "startuplite3"]:4: '=' expected=(
199 posts
Location
Switzerland
Posted 10 April 2013 - 06:23 AM
sorry should be
root = "18bq095q"
file = "startup"
shell.run("pastebin", "get", root, file)
2088 posts
Location
South Africa
Posted 10 April 2013 - 06:38 AM
You're trying to use http.get url as the url WITH the file name!
local url = "http://pastebin.com/raw.php?i=18bq095q/"
local fileName = "startup"
local response = http.get(url)
if response then
local file = fs.open( file, "w" )
file.write( response.readAll() )
file.close()
response.close()
else
print("Failed!")
end
os.reboot()
7508 posts
Location
Australia
Posted 10 April 2013 - 06:51 AM
I would like to point out that the OP says that the problem is that the pastebin source is being downloaded……
The reason for that is because this
http://pastebin.com/raw.php?i=18bq095q/
cannot have a / on the end, or 'startup' (which you are doing with http.get(root..file))
if you change it to
root = "http://pastebin.com/raw.php?i=18bq095q"
and
local response = http.get(root)
Also I would like to say that to all you that told OP to use the pastebin program, this is
not a fix to the problem, yes it is a way to get around it, but it's not a fix… and part of the reason most 'good' OS installers do not use the pastebin program is because the program prints out information which can ruin GUIs and/or just look bad…
379 posts
Location
Hawaii
Posted 10 April 2013 - 10:42 AM
You're trying to use http.get url as the url WITH the file name!
local url = "http://pastebin.com/raw.php?i=18bq095q/"
local fileName = "startup"
local response = http.get(url)
if response then
local file = fs.open( file, "w" )
file.write( response.readAll() )
file.close()
response.close()
else
print("Failed!")
end
os.reboot()
Fixed incorrect variable name
local file = fs.open( fileName, "w" )
199 posts
Location
Switzerland
Posted 10 April 2013 - 07:51 PM
I would like to point out that the OP says that the problem is that the pastebin source is being downloaded……
The reason for that is because this
http://pastebin.com/raw.php?i=18bq095q/
cannot have a / on the end, or 'startup' (which you are doing with http.get(root..file))
if you change it to
root = "http://pastebin.com/raw.php?i=18bq095q"
and
local response = http.get(root..file)
Also I would like to say that to all you that old OP to use the pastebin program, this is
not a fix to the problem, yes it is a way to get around it, but it's not a fix… and part of the reason most 'good' OS installers do not use the pastebin program is because the program prints out information which can ruin GUIs and/or just look bad…
Hm, good point actually maybe i should try to fix the problem first before posting workaround… and good to know about the pastebin program, will keep this in mind.