Click here to get back home

1st process' exit code

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
1st process' exit code dae3 07-14-2008
Posted by dae3 on July 14, 2008, 11:10 am
Please log in for more thread options
Let's say I have two programs: 'foo' and 'bar'. 'foo' always returns an
exit code of 10. 'bar' always exits normally (i.e. returns 0).

If I do: `foo | bar` in my shell, the shell will return 10.

If I do: exec('foo | bar', $ignoreMe, $returnCode) in PHP, $returnCode
will contain 0.

Is there a way to detect a pipe's first process' exit code in PHP ?

Background info and an idea: my shell is tcsh. In the above example,
tcsh and csh report the 10 exit code, whereas bash and sh would return
0. Thus, the above question *might* be equivalent to: "Is there a way to
specify in which shell 'exec' should execute commands?"

Thanks in advance...


--
I am dae3 and I approve my own message.
---------------------------------------'
"Little else matters than to write good code."
(Karl Lehenbauer)

Posted by C. (http://symcbean.blogspot.c on July 15, 2008, 8:46 am
Please log in for more thread options
> Let's say I have two programs: 'foo' and 'bar'. 'foo' always returns an
> exit code of 10. 'bar' always exits normally (i.e. returns 0).
>
> If I do: `foo | bar` in my shell, the shell will return 10.
>
> If I do: exec('foo | bar', $ignoreMe, $returnCode) in PHP, $returnCode
> will contain 0.
>
> Is there a way to detect a pipe's first process' exit code in PHP ?
>
> Background info and an idea: my shell is tcsh. In the above example,
> tcsh and csh report the 10 exit code, whereas bash and sh would return
> 0. Thus, the above question *might* be equivalent to: "Is there a way to
> specify in which shell 'exec' should execute commands?"
>
> Thanks in advance...

This may be obvious, but....

1) Implement the '|' in your own PHP code, and call proc_open twice.
(or use a Unix socket inbetween but still invoke the programs
independently from your own code)

2) exec("sh 'foo | bar'");

beyond that....ask on tcsh group?

C.



Similar ThreadsPosted
Process batch code September 20, 2004, 9:42 am
[OT] Survey: die vs. exit August 13, 2004, 1:40 am
exit not working August 29, 2006, 10:55 am
exit link url variable? October 9, 2006, 7:07 pm
releasing resources and exit; February 4, 2008, 7:17 am
programs taking too long to exit April 2, 2007, 10:48 am
Error in my_thread_global_end(): 3 threads didn't exit May 6, 2007, 6:10 am
Error in my_thread_global_end(): 1 threads didn't exit. February 4, 2008, 11:19 am
include 'filename.php' vs. exit 'whatever' May 26, 2008, 10:51 pm
exit interrupts my unit test June 25, 2008, 6:01 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap