OpenComputers Von Neumann Machine Programs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1001 B

  1. local shell = require("shell")
  2. local internet = require("internet")
  3. local fs = require("filesystem")
  4. local ll = require("liblua")
  5. local args = {...}
  6. -- Error checking
  7. if args[1] == nil then
  8. print("URL must exist")
  9. return
  10. end
  11. args[1] = "http://bacon.cosi.clarkson.edu:60005/"..args[1]
  12. -- Get local filename
  13. local fileName = ""
  14. if args[2] == nil then
  15. local t = ll.split(args[1], "/")
  16. fileName = t[#t]
  17. else
  18. fileName = args[2]
  19. end
  20. local newArgs = ll.slice(args, 3, #args-2)
  21. -- Sandbox so we don't write to the screen
  22. sandbox_env = {
  23. assert = assert,
  24. require = require,
  25. pairs = pairs,
  26. pcall = pcall,
  27. tostring = tostring,
  28. string = string,
  29. io = {write = function(...) end, read = io.read, open = io.open, stderr = io.stderr}
  30. }
  31. pcall(fs.remove, fileName)
  32. shell.execute("wget -f "..args[1].." "..fileName, sandbox_env)
  33. -- Run downloaded file
  34. local c = fileName
  35. for _, i in ipairs(newArgs) do c = c.." "..i end
  36. shell.execute(c)
  37. -- wget -f http://mc.bashed.rocks:13699/grab-run.lua