This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
lieudusty's profile picture

Remote Shell?

Started by lieudusty, 10 August 2012 - 04:49 AM
lieudusty #1
Posted 10 August 2012 - 06:49 AM
Hi everyone! ;)/>/>

I'm making a program and I need a remote shell. I have no idea/concept on how to do this. (Clueless) Can someone kindly show me the concept of this and/or the code for it? Thanks
BigSHinyToys #2
Posted 10 August 2012 - 07:03 AM
Remote Terminal login/controll system

This might help it is a bit advanced / complex But it has terminal redirect capability built into it.
KaoS #3
Posted 10 August 2012 - 09:48 AM
I made a basic remote program that I found very useful, basically you place a PC and then send it the code it must execute with a code/key to verify that this computer must run it

CLIENT STARTUP FILE:

local keyword="1234"
rednet.open(whateversideyourmodemison)
while true do
local id,msg,dist=rednet.receive()
temp=textutils.unserialize(msg)
if type(temp)=="table" and temp[1]==keyword then
loadstring(temp[2])()
end
end

HOW TO SEND DATA:
basically you make the code (eg: 'turtle.up() turtle.place() turtle.down()') in string form - THIS IS IMPORTANT, MUST BE A STRING OR WON'T SERIALIZE
then you make the keyword(eg: '1234')
put them into a table like so

mytable={}
mytable[1]="1234"
mytable[2]="turtle.up() turtle.place() turtle.down()"

and then send it in serialized form


rednet.open(modemside)
rednet.broadcast(textutils.serialize(mytable))

this can be summarized into 2 lines


rednet.open(modemside)
rednet.broadcast(textutils.serialize({keyword,code}))

so you no longer have to store any programs on your computers, you just send them their tasks from the host computer, you can even tell them to send the output back etc etc