4
votes

When I'm trying to execute a PHP script using shell_exec(), it's not working.

In the error_log file it shows:

PHP Warning: shell_exec() [function.shell-exec]: Unable to execute 'php /home/snabbsam/public_html/.....

System
Centos

shell_exec works with clamscan
shell_exec() works on clamscan() function of clamav.
But it's not executing PHP script

Things I've checked:

1
Have you tried adding a full path to the php executable? I doubt it'll make a difference, but it certainly can't hurt. - andrewsi
intitially i used $seoutput = shell_exec('php /home/...'); After your suggestion, I used $seoutput = shell_exec('/usr/local/lib/php /home/s..'); Now there's no entry in error_log, $seoutput is blank & there's no output. Also the target script is not getting executed - Anish
No, I meant adding the path to where php can be found. - andrewsi
You'll need to find the php executable, not the config file - andrewsi
Huh. You'd've thought that PHP would know where its own executable was. The mysteries of file permissions and environment variables are clearly too complex for me before my second coffee of the day. - andrewsi

1 Answers

5
votes

Try adding a full path to where the executable for php is in your shell_exec call, just in case it's in a directory that's not accessible by default for the webserver user.