Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("rnc2")
- os.loadAPI("ldb2")
- local prg = shell.getRunningProgram()
- local label = os.getComputerLabel()
- if label == nil then
- return
- end
- function string.starts(String,Start)
- return string.sub(String,1,string.len(Start))==Start
- end
- local function isempty(s)
- return s == nil or s == ''
- end
- function string.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
- rnc2.setTimeOut(prg, 99)
- rnc2.setPort(prg, 600)
- rnc2.setIdenty(prg, 100)
- while true do
- rnc2.setIdenty(100)
- local res = rnc2.resive(prg)
- if not isempty(res) and string.starts(res, label .. " ") then
- res = string.sub(res,string.len(label) + 2,string.len(res))
- print("resived message:\"" .. res .. "\"")
- rnc2.setIdenty(prg, 101)
- rnc2.send(prg,label .. "> Command resived!")
- rnc2.setIdenty(prg, 100)
- if not shell.run(res) then
- local temp = string.split(res, " ")
- tempsize = table.getn(temp)
- local inside = ""
- for i = 1, tempsize do
- inside = inside .. '"' .. temp[i] ..'"'
- if i ~= tempsize then
- inside = inside .. ","
- end
- end
- func = loadstring("shell.run(".. inside ..")")
- setfenv(func, getfenv())
- func()
- end
- end
- end
- print("magic")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement