Wardes

getGithub

May 4th, 2021 (edited)
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.61 KB | None | 0 0
  1. --By Wardes
  2. url = ""
  3. mPath = "buffer"
  4.  
  5. if url ~= "" then
  6.   local res = http.get(url)
  7.   if res then
  8.     if fs.exists(mPath) then
  9.       shell.run("rm", mPath)
  10.     end
  11.  
  12.     local file = fs.open( mPath, "w" )
  13.     file.write(res.readAll())
  14.     file.close()
  15.     res.close()
  16.     term.setTextColor (colors.green)
  17.     print("Downloaded as " .. mPath)
  18.     term.setTextColor(colors.white)
  19.     shell.run("clear")
  20.     shell.run(mPath)
  21.   else
  22.     term.setTextColor(colors.red)
  23.   print("No data detected")
  24.   end
  25. else
  26.   term.setTextColor(colors.red)
  27.   print("No url detected")
  28. end
  29. term.setTextColor(colors.white)
  30.  
Add Comment
Please, Sign In to add comment