Posted 10 April 2015 - 07:31 AM
Hello I was wondering is there a way I can make a pastbin run code download another pastebin file install it then reboot OS or is it not possible?
function get(sCode,sFile)
local sPath = shell.resolve( sFile )
if fs.exists( sPath ) then
return false
end
local response = http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode( sCode ))
if response then
local sResponse = response.readAll()
response.close()
local file = fs.open( sPath, "w" )
file.write( sResponse )
file.close()
return true
else
return false
end
end
It returns true if the file was downloaded, false if it couldn't for any reason
local problem = false
if not get("code1","path1") then
print("Could not download 'path1' program")
problem = true
else
print("Downloaded 'path1' shortcut program")
end
if not get("code2","path2") then
print("Could not download 'path2' program")
problem = true
else
print("Downloaded 'path2' program")
end
--# ect
if problem then
term.setTextColor(colors.red)
print("Something when wrong. Program was not installed correctly")
else
term.setTextColor(colors.lime)
print("Program installed!")
end
os.reboot()