|
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.
|