local args = {...} function usage() term.setTextColor(colors.red) print("Usage:") print("ssh [port]") print("ssh open [port]") print("ssh broadcast [port] ") term.setTextColor(colors.white) end if #args < 1 then usage() else if #args > 4 then usage() else if args[1] == "broadcast" then if #args > 3 then local server = rednet.lookup(args[3], args[4]) if server then rednet.broadcast(args[2], args[3]) print("Broadcasted: \"", args[2], "\" to: \"", args[3]) else print("Error: Secure shell server does not exist!") end else local server = rednet.lookup(args[3], "25674") if server then rednet.broadcast(args[2], args[3]) print("Broadcasted: \"", args[2], "\" to: \"", args[3]) else print("Error Secure shell server does not exist!") end end else if args[1] == "open" then local id = os.getComputerID() if #args == 1 then print("Trying to open on id: ", id, " Port: 25674") rednet.open("top") local ids = tostring(id) rednet.host(ids, "25674") else print("Trying to open on id: ", id, " Port: ", args[2]) rednet.open("top") local ids = tostring(id) rednet.host(ids, args[2]) end else if #args == 1 then print("Trying: ", args[1]) rednet.open("top") local server = rednet.lookup(args[1], "25674") if server then print("Entering secure shell server!") while true do local id, rec = rednet.receive(args[1]) print(id, ":", rec) os.sleep(1) end else print("Error: Secure shell server does not exist!") end else if #args == 2 then print("Trying: ", args[1], " port:", args[2]) rednet.open("top") local server = rednet.lookup(args[1], args[2]) if server then print("Entering secure shell server!") while true do local id, rec = rednet.receive(args[1]) print(id, ":", rec) os.sleep(1) end else print("Error: Secure shell server does not exist!") end end end end end end end