asteroidsteam

download

Dec 12th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.51 KB | None | 0 0
  1. local args = {...}
  2. function usage()
  3. print("Usage: download <web adress> <file>")
  4. end
  5. if #args < 2 then
  6. usage()
  7. else
  8. if #args > 2 then
  9. usage()
  10. else
  11. local file = fs.open(args[2], "w")
  12. local url = "http://"..args[1]
  13. local curl = http.checkURL(url)
  14. if curl then
  15. print("Downloading...")
  16. se = http.get(url)
  17. file.write(se.readAll())
  18. file.close()
  19. se.close()
  20. print("Download Complete!")
  21. else
  22. print("Downloading...")
  23. os.sleep(2)
  24. print("Error Downloading: incorrect URL or no internet connection!")
  25. end
  26. end
  27. end
Add Comment
Please, Sign In to add comment