20 posts
Posted 02 August 2012 - 09:47 PM
Is it possible to download from pastebin using a script?
example:
file = io.open("test.lua", "r")
if file==nil then
pastebin get Hgt6Hyt test.lua <— How do I do this part within a script
else
print("test.lua file has been found and is readable")
end
3790 posts
Location
Lincoln, Nebraska
Posted 02 August 2012 - 09:57 PM
There is a Http API that does just that:
Right Here
1604 posts
Posted 02 August 2012 - 10:00 PM
You can also take a look at the pastebin program, to know how it downloads the file.
This is the part for downloading:
-- Determine file to download
local sCode = tArgs[2]
local sFile = tArgs[3]
local sPath = shell.resolve( sFile )
if fs.exists( sPath ) then
print( "File already exists" )
return
end
-- GET the contents from pastebin
write( "Connecting to pastebin.com... " )
local response = http.get(
"http://pastebin.com/raw.php?i="..textutils.urlEncode( sCode )
)
if response then
print( "Success." )
local sResponse = response.readAll()
response.close()
local file = fs.open( sPath, "w" )
file.write( sResponse )
file.close()
print( "Downloaded as "..sFile )
else
print( "Failed." )
end
474 posts
Posted 02 August 2012 - 10:17 PM
pastebin get Hgt6Hyt test.lua <— How do I do this part within a script
shell.run("pastebin","get","Hgt6Hyt","test.lua")
20 posts
Posted 02 August 2012 - 10:23 PM
Thanks a lot guys… Not sure why im surprised, I did went to the pro section after all :ph34r:/>/>