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

Running Command With Rednet

Started by toniko, 24 February 2012 - 12:52 PM
toniko #1
Posted 24 February 2012 - 01:52 PM
Hello, I'm trying to run a command (eg turtle.back ()) using the rednet. however so far without success. Could someone help me?
Liraal #2
Posted 24 February 2012 - 02:48 PM
That's, to say the least, problematic. The thing is that what you can send over rednet is a string. To actually execute a function it needs to be code. I haven't yet found a way around this. However, if you can pre-program all the functions/commands into files already present in the receiver's file system, you can use something like that:

local path=NAME -- swap NAME for path to the program to execute. ofc you can have many of these
while true do
local e, i, m=os.pullEvent()
if a=="rednet_message" and m==path then
shell.run(path)
end
end
If you run this, just send to that terminal the path entered in the first line of code.
if you want more options, just duplicate the 'if' section.
ChaosBeing #3
Posted 26 February 2012 - 08:49 AM
http://www.computercraft.info/forums2/index.php?/topic/226-send-arbitrary-commands-over-wifi/page__hl__shell.run__fromsearch__1

That should help you.