NYCPHP Meetup

NYPHP.org

[nycphp-talk] passthru() return codes

Greg Rundlett greg.rundlett at gmail.com
Thu Dec 1 00:41:18 EST 2005


On 11/30/05, Jeff Loiselle <jeff.loiselle at gmail.com> wrote:
> Anyone know where I can find an exhaustive list of return codes for
> functions like exec() and passthru()? Apparently, I'm Google Retarded
> today.
>
exec() doesn't return codes

exec() returns a string.

The string returned is the last line of output from whatever system
command you exec'd, which may or may not be very useful to you.

$strResult = exec('cat myLongTextFile.txt');

will give you the last line of that text file.  You can optionally set
the argument to the exec() function to capture all the output of the
system command, but that's not what you're asking, so excuse me for
being pedantic.

The passthru() command is capable of returning the return code of the
system call.  As noted in the manual http://php.net/passthru

void passthru ( string command [, int &return_var] )

For some of the special return codes that are possible from the BASH
environment, see http://www.tldp.org/LDP/abs/html/exitcodes.html

If you need more information about the process that you're trying to
run, including the return code, you might have better luck with the
proc_open() function which is pretty nifty.

Good luck.



More information about the talk mailing list