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

running a shell.run from an if statement?

Started by jimyh, 27 May 2015 - 07:14 PM
jimyh #1
Posted 27 May 2015 - 09:14 PM
Hello kind people, ok so this sounds so simple yet I cannot get it to work. I have a main computer sending a message 'on' to a slave computer. The slave is listening out for this message and receives it fine, however when I check the equality of the message to run another program it does not run it. It seems to skip the if then statement and prints 'running'. I have tried using speech quotations and parentheses but it still does not work. you help would be greatly appreciated.
Creator #2
Posted 27 May 2015 - 09:25 PM

term.clear()
print ("Laser 3")
rednet.open("left")
id, message = rednet.receive()
print (message)
if message == "on" then
  shell.run(lime)
end
print ("running")

I corrected the code. The main error is that you confuse strings with variables
Edited on 27 May 2015 - 07:26 PM
jimyh #3
Posted 27 May 2015 - 09:31 PM
thank you for your input, however I have tried the code exactly as you typed it, previously. I have just re-checked that way and unfortunately it still does not run the program.
Creator #4
Posted 27 May 2015 - 09:40 PM
what message does it send?

what does it print?
jimyh #5
Posted 27 May 2015 - 09:42 PM
my master computer sends user input. user input is 'on' for turning it on and will be 'off' for the obvious. my program runs through and even prints running at the end but does not execute the lime program?
Creator #6
Posted 27 May 2015 - 09:47 PM
can you post te whole code on pastebin?
SGunner2014 #7
Posted 27 May 2015 - 09:49 PM
This should be in the 'Ask a Pro' section.
Cranium #8
Posted 27 May 2015 - 09:53 PM
This should be in the 'Ask a Pro' section.
Indeed. Moved.
jimyh #9
Posted 27 May 2015 - 09:56 PM
ok, startup yw7X9LiA, lime eToEgviV, test p4kgviV. startup and lime are on the 'slave' computer and the test program is on the master. thanks.
flaghacker #10
Posted 27 May 2015 - 11:07 PM
It should be

shell.run ("lime")
Mind the quotes…

@Creator I think you're confusing strings and variables :P/> (just trolling, don't get mad pls)
Edited on 27 May 2015 - 09:08 PM
Creator #11
Posted 28 May 2015 - 05:35 AM
lol, you're right
jimyh #12
Posted 28 May 2015 - 08:40 AM
Omg, such a simple fix, can't believe I didn't see it. Thanks to all.