Advertisement
Tatantyler

RPC-Based SSH Client

Oct 28th, 2012
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.81 KB | None | 0 0
  1. local args = {...}
  2.  
  3. if #args == 1 then
  4.     for i,v in ipairs(rs.getSides()) do
  5.         if peripheral.getType(v) == "modem" then
  6.             rednet.open(v)
  7.         end
  8.     end
  9.  
  10.     os.loadAPI("rpc")
  11.     --rpc.setDebug(true)
  12.     rpc.loadAPI("rom/apis/term")
  13.     rpc.loadAPI("rom/apis/textutils")
  14.     rpc.loadAPI("rom/apis/io")
  15.     --[[for i,v in ipairs(fs.list("rom/apis")) do
  16.         rpc.loadAPI("rom/apis/"..v)
  17.     end]]
  18.     rpc.new("write", "local args = {...} return write(args[1])")
  19.     rpc.new("print", "local args = {...} return print(unpack(args))")
  20.     rpc.new("read", "return read()")
  21.     rpc.new("pullEvent", "return os.pullEvent(...)")
  22.     rpc.new("pullEventRaw", "return os.pullEventRaw(...)")
  23.     term.clear()
  24.     term.setCursorPos(1,1)
  25.     parallel.waitForAll(
  26.     function() rednet.send(tonumber(args[1]), "connect") end,
  27.     rpc.run)
  28. else
  29.     print("USAGE: client [id]")
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement