I'm controlling my home automation with a Raspberry Pi and webserver. I use this line to turn on my lights (sending an RC signal to wireless power socket).
exec("sudo ./../../../home/pi/wiringPi/examples/lights/action 63 A on");
This is working when the script is ran by a cron job, but when I manually want to execute this command (using a php form and buttons), it does not work. I tried adding $output, $return);
and checking $return
, and that confirms the exec() function is not executed. However, when I use something like exec("whoami");
, the script is executed.
What is it about my command that makes it work only in cron jobs? I had this working once, don't know what happened. Manually sending the command via ssh in the terminal is working normally.