Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function help()
- print("Usage:")
- print("aget <postname> <name>");
- end
- local tArgs = { ... }
- if #tArgs < 2 or tArgs[1] == "help" then
- help()
- return
- end
- if not http then
- print( "AGET requires http API" )
- return
- end
- local id = tArgs[1]
- local fname = tArgs[2]
- local sFile = shell.resolve(fname)
- if fs.exists(sFile) then
- print("File already exists.")
- return
- end
- write("Attempting to connect to ipeer.auron.co.uk...")
- local r = http.get("http://ipeer.auron.co.uk/ftb/scripts/"..textutils.urlEncode(id))
- if r then
- print("OK.")
- local sr = r.readAll()
- r.close()
- local f = fs.open(sFile, "w")
- f.write(sr)
- f.close()
- print ("Saved as "..fname)
- else
- print("Failed.")
- end
Advertisement
Add Comment
Please, Sign In to add comment