Re: Problem with the passthru function
| From: | Richard Lynch | Date: | Thu, 15 Jun 2006 07:37:40 +0000 |
| Subject: | Re: Problem with the passthru function | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-238050@lists.php.net to get a copy of this message | ||
On Wed, June 14, 2006 4:51 am, Venkatesh Babu wrote:
> I have a small php file (test.php) whose code is shown
> below:
>
> <?php
> $retval=1;
> $command='/bin/ls';
> passthru($command, $retval);
> print("Exit status: " . $retval);
> ?>
>
> This test.php works fine when I execute from command
> prompt as "php test.php", but when I access it through
> web browser, it seems not to be working fine, I get an
> exit status of 127 (which means command not found). I
> checked for permissions of ls, gave full path, but
> still it is failing.
>
> Can anybody help me in indentifying what is the
> potential problem?
That is pretty odd, as you seem to have covered the Usual Mistakes...
I guess my next move would be to try:
if (file_exists('/bin/ls')){
echo "Okay, /bin/ls does exist.<br />\n";
}
else{
echo "Hmmm... PHP says /bin/ls does not exist.<br />\n";
}
if (is_executable('/bin/ls')){
echo "Okay, /bin/ls is executable.<br />\n";
}
else{
echo "hmmm... PHP says /bin/ls is not executable.<br />\n";
}
and so on...
Try every which way from PHP to check out /bin/ls to see if it is there.
I suppose it's also possible that the default Environment for PHP is
attempting to ls a directory for which you do not have access...
Try using '/bin/ls /full/path/to/your/web/tree' instead.
--
Like Music?
http://l-i-e.com/artists.htm