Guest User

1

a guest
Jul 15th, 2017
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.16 KB | None | 0 0
  1. wget = function(option, url, ziel)
  2.   if type(url) ~= "string" and type(ziel) ~= "string" then
  3.     print("Benutzung:")
  4.     print("wget [-f] <URL> <Ziel>")
  5.     return
  6.   end
  7.   if http.checkURL(url) then
  8.     if fs.exists(ziel) and option ~= "-f" then
  9.       print("Ziel existiert bereit")
  10.       return
  11.     else
  12.       print("Starte Download ... ")
  13.       local timer = os.startTimer(30)
  14.       http.request(url)
  15.       while true do
  16.         local event, _, data = os.pullEvent()
  17.         if event == "http_success" then
  18.           print("Download erfolgreich")
  19.           local f = io.open(ziel, "w")
  20.           f:write(data.readAll())
  21.           f:close()
  22.           data:close()
  23.           print("Gespeichert unter " .. ziel)
  24.           return true
  25.         elseif event == "timer" then
  26.           print("<Fehler> Zeitberschreitung")
  27.           return
  28.         elseif event == "http_failure" then
  29.           print("<Fehler> Download")
  30.           return
  31.         end
  32.       end
  33.     end
  34.   else
  35.     print("<Fehler> URL")
  36.     return
  37.   end
  38. end
  39.  
  40. wget("-f", "https://raw.githubusercontent.com/Nex4rius/Nex4rius-Programme/master/Stargate-Programm/stargate/Kontrollprogramm.lua", "/2")
Advertisement
Add Comment
Please, Sign In to add comment