Jump to content




Remote shell?


  • You cannot reply to this topic
6 replies to this topic

#1 lieudusty

  • Members
  • 419 posts

Posted 30 October 2012 - 12:03 AM

Hi everyone! :P/>

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 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 30 October 2012 - 12:43 AM

Use a redirect table to transmit the term calls and their parameters to the remote machine.

#3 lieudusty

  • Members
  • 419 posts

Posted 30 October 2012 - 01:54 AM

View PostLyqyd, on 30 October 2012 - 12:43 AM, said:

Use a redirect table to transmit the term calls and their parameters to the remote machine.
Can you show me a small example of getting the redirect table? I can't seem to find it in the term api

#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

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 lieudusty

  • Members
  • 419 posts

Posted 30 October 2012 - 02:38 AM

View PostLyqyd, 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
Thanks! That helped me quite a lot considering its not finished but I get the concept now :P/> Thanks
EDIT: Arg.... I tried coding it but turns out I still don't get the concept. :/ Can someone explain this more clearly?

#6 faubiguy

  • Members
  • 213 posts

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 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

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