Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tArgs = { ... }
- function help()
- print("weGet <URL> <file>")
- end
- if http then
- if #tArgs < 1 then
- help()
- error("Missing file URL")
- elseif #tArgs < 2 then
- help()
- error("Missing saved file name")
- elseif #tArgs > 2 then
- help()
- error("Too much arguments")
- else
- print("Trying to get " .. tArgs[2] .. " from " .. tArgs[1])
- file = http.get(tArgs[1])
- if file == nil then
- error("There's no such file")
- else
- print("Got " .. tArgs[2])
- saved = fs.open(shell.resolve("") .. "/" .. tArgs[2], "w")
- saved.write(file.readAll())
- saved.close()
- print("Successfully saved the file!")
- file = nil
- saved = nil
- end
- end
- else
- error("weGet needs HTTP!")
- end
Advertisement
Add Comment
Please, Sign In to add comment