Page 1 of 1

Return value in PHP shell script

Posted: Sat Jan 18, 2003 3:05 pm
by dajudge
Hello.

I do require a way to return values from a php script which is used as a shell script on a linux system.

Assume the following file 'test.php':

Code: Select all

#!/usr/local/sbin/php -q
<?php
return 0;
?>
If I now execute the following line at the command line:

./test.php && echo Hello

it indeed does execute the echo call as well although I do return 0 from the script. So I assume that returning a value from the global namespace does not determine the value returned by the php script interpreter.

However, I du actually require this behaviour as I indent to use a PHP script in a .qmail file which changes processing behaviour depending on the return values of the executables.

I do use the PHP 4.3.0

I hope you can help me with that.

Thanks in advance,
Alex

Posted: Sun Jan 19, 2003 12:15 am
by volka
try

Code: Select all

<?php
exit(-1);
?>
instead

Posted: Sun Jan 19, 2003 2:37 am
by dajudge
This worked really fine for me! Thanks.