Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- local client
- function myWrite(...)
- rednet.send(client,write)
- rednet.send(client,table.concat({...}," "))
- end
- function rednetTarget(id)
- client = id
- return
- {
- write=function(...) paralell.waitForAll(,) end
- getSize = term.getSize
- }
- end
- function run(id,prog,...)
- term.redirect(rednetTarget(id))
- local ret = shell.run(prog,...)
- term.restore()
- return ret
- end
- function split(s)
- local t = {}
- for v in string.gmatch(s,"[^%s]+") do
- t[#t+1]=v
- end
- return t
- end
- while true do
- local id,msg = rednet.receive()
- local cmd,args=string.gmatch(msg,"(.-) (.*)$")()
- print("'"..args.."' "..id)
- if args then
- args=split(args)
- print(args[1])
- ret = run(id,cmd,unpack(args))
- else
- ret = run(id,cmd)
- end
- rednet.send(id,tostring(ret))
- rednet.send(id,"end")
- end
- rednet.close("right")
Advertisement
Add Comment
Please, Sign In to add comment