Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Remote Terminal Client
- by BigShinyToys
- OPEN SOURCE CODE (no rights reserved)
- ]]--
- local SeverID = nil
- local asa = 1 -- test mode
- local function runner()
- term.clear()
- term.setCursorPos(1,1)
- while true do
- local e1,e2,e3,e4,e5 = os.pullEvent()
- if e1 == "rednet_message" then -- and e2 == SeverID
- local sTest = string.sub(e3,1,3)
- if sTest == "WRT" then
- write(string.sub(e3,4,#e3))
- elseif sTest == "CLR" then
- term.clear()
- elseif sTest == "CLL" then
- term.clearLine()
- elseif sTest == "SCB" then
- local boolin = string.sub(e3,4,#e3)
- if boolin == "true" then
- term.setCursorBlink(true)
- elseif boolin == "false" then
- term.setCursorBlink(false)
- end
- elseif sTest == "SCP" then
- local curP = textutils.unserialize(string.sub(e3,4,#e3))
- term.setCursorPos(curP[1],curP[2])
- elseif sTest == "GSZ" then -- work on this
- rednet.send(SeverID,"SIZ"..textutils.serialize({term.getSize()}))
- elseif sTest == "GCP" then
- rednet.send(SeverID,"POS"..textutils.serialize({term.getCursorPos()}))
- elseif sTest == "SCR" then
- term.scroll(tonumber(string.sub(e3,4,#e3)))
- end
- elseif e1 == "key" then
- rednet.send(SeverID,"key"..tostring(e2))
- rednet.send(asa,"key"..tostring(e2))
- elseif e1 == "char" then
- rednet.send(SeverID,"cha"..e2)
- rednet.send(asa,"cha"..e2)
- end
- end
- end
- local function openRednet()
- local listOfSides = rs.getSides()
- for i = 1,6 do
- if peripheral.isPresent(listOfSides[i]) and peripheral.getType(listOfSides[i]) == "modem" then
- rednet.open(listOfSides[i])
- return listOfSides[i]
- end
- end
- end
- modemOn = openRednet()
- if not modemOn then
- print("No WIFI ModemnPress any key to return to exit")
- os.pullEvent("key")
- return
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Welcom to remote terminal")
- print("Sever ID")
- SeverID = tonumber(read())
- print("User Name :")
- local UserName = read()
- print("Password")
- local UserPass = read("*")
- print("authenticating")
- rednet.send(SeverID,"RMTLOGINREQ:"..textutils.serialize({UserName,UserPass}))
- while true do
- local e1,e2,e3,e4,e5 = os.pullEvent()
- if e1 == "rednet_message" then
- if e2 == SeverID then
- if e3 == "Request Accepted" then
- runner()
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment