Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ pastebin get 4UpdHNnr /programs/link --]]
- local data= "id_machine="..os.getComputerID().."&name=test"
- local links ={}
- links.machine = "http://pbserver.altervista.org/COMPUTERCRAFT/API/machine.php"
- links.core = "http://pbserver.altervista.org/COMPUTERCRAFT/OS/core.php"
- local function printReq(url,data)
- local req,req_response
- if not data then
- req= http.get(url)
- else
- req= http.post(url, data)
- end
- req_response=req.readAll()
- req.close()
- return req_response
- end
- function split (inputstr, sep)
- if sep == nil then
- sep = "%s"
- end
- local t={}
- for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
- table.insert(t, str)
- end
- return t
- end
- if(printReq(links.machine.."?id_machine="..os.getComputerID())=="0 results") then
- printReq(links.machine,"id_machine="..os.getComputerID())
- end
- while(true) do
- local result= printReq(links.core.."?id_machine="..os.getComputerID())
- if(command~="null") then
- result=split(result,",")
- if not result[3] then
- result[3]=""
- end
- local status=shell.run(result[2],result[3])
- if status== true then
- status="1"
- else
- status="0"
- end
- print(result[2]..": "..result[3])
- printReq(links.core,"id_command="..result[1].."&status="..status)
- end
- os.sleep(30)
- end
Add Comment
Please, Sign In to add comment