[nycphp-talk] passthru() return codes
Jeff Loiselle
jeff.loiselle at gmail.com
Thu Dec 1 09:21:02 EST 2005
Greg,
Thanks for the reply. But after nobody replied yesterday, I pretty
much figured it all out. ;-) passthru() does return error codes.. and
apparently it can send error codes from a variety of places.. i've
recieved operating system errors codes if it can't find the specified
program... but it took me a while to figure out it also returns the
error codes of the application you are trying to execute... once i
figured that out, everything went fine. ;-)
> The passthru() command is capable of returning the return code of the
> system call.
When I see comments like this, I assume systems calls meaning things
like 'stat'.. not things like 'unzip'. ;-) So that's slightly
confusing, especially when you're not sure if the error codes are
coming from the OS or the program you are executing.
thanks.
On 11/30/05, Greg Rundlett <greg.rundlett at gmail.com> wrote:
> 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.
> _______________________________________________
> New York PHP Talk Mailing List
> AMP Technology
> Supporting Apache, MySQL and PHP
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.nyphp.org
>
--
---
Jeff Loiselle
Web Developer, Musician, and Observer
http://jeff.loiselles.com
"In America, through pressure of conformity, there is freedom of
choice, but nothing to choose from." - Peter Ustinov
More information about the talk
mailing list