Return value in PHP shell script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dajudge
Forum Newbie
Posts: 2
Joined: Sat Jan 18, 2003 3:05 pm

Return value in PHP shell script

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

try

Code: Select all

<?php
exit(-1);
?>
instead
dajudge
Forum Newbie
Posts: 2
Joined: Sat Jan 18, 2003 3:05 pm

Post by dajudge »

This worked really fine for me! Thanks.
Post Reply