Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args = {...}
- if args[1] == nil or args[2] == nil then
- return print ("usage: "..shell.getRunningProgram().." <url> <name>")
- end
- check = string.sub(args[1], 1, 7)
- if check == "http://" then
- args[1] = string.sub(args[1], 8, #args[1])
- end
- http.request("http://"..args[1])
- event,url,source = os.pullEvent()
- if event == "http_success" then
- text = source.readAll()
- if fs.exists(args[2]) then
- fs.delete(args[2])
- end
- file = fs.open(args[2], "w")
- file.write(text)
- file.close()
- print("downloaded as "..args[2])
- elseif event == "http_failure" then
- print "error"
- end
Advertisement
Add Comment
Please, Sign In to add comment