4

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:

7
  • 3
    Have you tried adding a full path to the php executable? I doubt it'll make a difference, but it certainly can't hurt. Commented Jul 13, 2012 at 13:46
  • 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 Commented Jul 13, 2012 at 13:54
  • 1
    No, I meant adding the path to where php can be found. Commented Jul 13, 2012 at 13:56
  • 2
    You'll need to find the php executable, not the config file Commented Jul 13, 2012 at 14:04
  • 1
    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. Commented Jul 13, 2012 at 14:23

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

To get path to the php executable use "which php" command as mentioned in serverfault.com/a/58388

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.