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.

44 lines
1.0 KiB

local shell = require("shell")
local internet = require("internet")
local fs = require("filesystem")
local ll = require("liblua")
local args = {...}
-- Error checking
if args[1] == nil then
print("URL must exist")
return
end
args[1] = "http://mc.bashed.rocks:13699/"..args[1]
-- Get local filename
local fileName = ""
if args[2] == nil then
local t = ll.split(args[1], "/")
fileName = t[#t]
else
fileName = args[2]
end
local newArgs = ll.slice(args, 3, #args-2)
-- Sandbox so we don't write to the screen
sandbox_env = {
assert = assert,
require = require,
pairs = pairs,
pcall = pcall,
tostring = tostring,
string = string,
io = {write = function(...) end, read = io.read, open = io.open, stderr = io.stderr}
}
pcall(fs.remove, fileName)
shell.execute("wget -f "..args[1].." "..fileName, sandbox_env)
-- Run downloaded file
local c = fileName
for _, i in ipairs(newArgs) do c = c.." "..i end
shell.execute(c)
-- wget -f http://mc.bashed.rocks:13699/grab-run.lua