Reputation: 10330
I have a script called turn_on.sh
.
I also have a script turn_off.sh
.
turn_on.sh
Starts a process
turn_off.sh
Simply kills the process (via kill -9 pid)
Running on the command line, everything works fine.
Calling these scripts from php simply doesn't work. I've tried shell_exec
, exec
, system
. Nothing seems to work. There is no errors anywhere.
I've tried chmod 777
both shell scripts. Still doesn't work.
Example code:
$val3 = exec($to_run,$val2,$val);
$val2 and $val having nothing in them.
PHP safe_mode
is off
Upvotes: 0
Views: 1022
Reputation: 3838
This may be due to several reasons:
1) You run your PHP script via apache, so the www-data user didn't have permission to run the two shells scripts.
2) You run your PHP script via apache, so the www-data user didn't have permission to start or kill the process.
3) ...
Try to redirect the standard and error outputs of your scripts in a log file for better analysis. You could also use set -x
to get a more complete debug trace.
Upvotes: 0