I'm trying to make a remote shell but I don't even have the concept on how to record the terminal and display it back on another computer. Can someone explain to me how this will work or the concept of it?
Remote shell?
Started by lieudusty, Oct 30 2012 12:03 AM
6 replies to this topic
#1
Posted 30 October 2012 - 12:03 AM
Hi everyone!
/>
I'm trying to make a remote shell but I don't even have the concept on how to record the terminal and display it back on another computer. Can someone explain to me how this will work or the concept of it?
I'm trying to make a remote shell but I don't even have the concept on how to record the terminal and display it back on another computer. Can someone explain to me how this will work or the concept of it?
#2
Posted 30 October 2012 - 12:43 AM
Use a redirect table to transmit the term calls and their parameters to the remote machine.
#4
Posted 30 October 2012 - 02:10 AM
You just kinda do this:
function redirectToID(targetID)
local redirectTable = {
sendTarget = targetID
}
redirectTable.write = function(text)
rednet.send(redirectTable.sendTarget, "WR"..text)
end
redirectTable.setCursorPos = function(x,y)
rednet.send(redirectTable.sendTarget, "SC"..x..","..y)
end
redirectTable.getCursorPos = function()
rednet.send(redirectTable.sendTarget, "GC")
id, message = rednet.receive(2)
if id == redirectTable.sendTarget then
if string.sub(message, 1, 2) == "CP" then
return string.match(message, "CP(%d+),(%d+)")
end
end
end
--etc
return redirectTable
end
#5
Posted 30 October 2012 - 02:38 AM
Lyqyd, on 30 October 2012 - 02:10 AM, said:
You just kinda do this:
function redirectToID(targetID)
local redirectTable = {
sendTarget = targetID
}
redirectTable.write = function(text)
rednet.send(redirectTable.sendTarget, "WR"..text)
end
redirectTable.setCursorPos = function(x,y)
rednet.send(redirectTable.sendTarget, "SC"..x..","..y)
end
redirectTable.getCursorPos = function()
rednet.send(redirectTable.sendTarget, "GC")
id, message = rednet.receive(2)
if id == redirectTable.sendTarget then
if string.sub(message, 1, 2) == "CP" then
return string.match(message, "CP(%d+),(%d+)")
end
end
end
--etc
return redirectTable
end
EDIT: Arg.... I tried coding it but turns out I still don't get the concept. :/ Can someone explain this more clearly?
#6
Posted 30 October 2012 - 04:06 AM
The redirect table contains a function to use in place of each function in the the term API. For example the write function would send a message to the target ID telling it to use term.write, the setCursorPos function would send a message to the target ID telling it to set the cursor position, the getCursorPos function would send a message to the target ID asking for the cursor position then wait for a response, and so on.
#7
Posted 30 October 2012 - 04:14 AM
Obviously, this requires a script on the other end listening for these packets and acting appropriately. There is a working example in LyqydNet, but obviously, the rednet operations are greatly simplified since it's dependent on LyqydNet. Here are the relevant portions of LyqydNet:
Spoiler
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











