Hey,

I'm having problem executing shell command as well as script using exec(), system(), or passthru(). It always return code 127, and even really simple script doesn't works :

<?php
exec("date",$date, $int);
print 'date :'.$date[0]."return value " .$int."<br>";
?>

I tried to change the permission of the file, move the file, change the owner of the file without any sucess.

My guess is that "php" doesn't have the right permission

any idea?

    I can't find a list of error codes for the exec() function, but I did find this on Google (from someone who was trying to run a Perl interpreter from PHP):

    I dunno what 127 actually means, but the last time we saw it on this list,
    it boiled down to:

    "You can't even run your 'sh' shell, much less Perl in that shell."

    Check what's in /bin/sh and what its permissions are.

    Make sure it's actually a valid shell binary, and not something bogus.

    If that's not it, keep digging.

    Somewhere, somehow, you've got something in permissions that is not
    allowing you to run a process/binary you need.

    So it's possible that the user under which the exec() call is being made (possibly apache, rather than php) doesn't even have access to the shell. The fact that you get the same error regardless of what command you try to execute lends credence to this hypothesis.

      Write a Reply...