473,471 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

1st process' exit code

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)
Jul 14 '08 #1
1 1810
On Jul 14, 4:10 pm, dae3 <7252d...@example.invalidwrote:
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.
Jul 15 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Peter Åstrand | last post by:
There's a new PEP available: PEP 324: popen5 - New POSIX process module A copy is included below. Comments are appreciated. ---- PEP: 324 Title: popen5 - New POSIX process module
3
by: felixfix | last post by:
Hi all, I am just wondering if something is wrong with my program. What it bascially does is to output a fibonacci sequence base on the command-line output. If I give a 5, it will generate the...
2
by: Tobias Johansson | last post by:
Hello, I'm having what I believe a security problem to execute an executable file from a windows service in windows server 2003. It works fine in WIN XP SP2 The program(the service) itself...
10
by: Tony | last post by:
I am running an application called AcroComm.exe to poll time clocks here at our company. I have written a small C# app that will poll the clocks based on information found in a DB. My problem is...
4
by: eva.monsen | last post by:
I'm trying to run a .BAT file using System.Diagnostics.Process. I'm having trouble getting Process.ExitCode to match up with what the .BAT file returns. Here are the contents of...
8
by: mandydhaliwal | last post by:
Hi all, I am porting a win32 c++ program on Linux which first reads a list of processes and their paths from a file.Then this program should launch all of thesese processes. I tried to...
1
by: vduber6er | last post by:
Hi I want to have a wait page while the rest of the cgi does its process, but it seems like the wait page waits till everything is complete and never appears. I've tried forking twice already as...
0
by: Cwappy | last post by:
I have a class that builds a DataTable and then, when the process is exiting, tries to write that DataTable to SQL Server 2000 via the SqlBulkCopy class. I know the process is exiting because I'm...
3
by: jbenezech | last post by:
Hi All, I have a perl script which starts a java process using Win32::Process. Here is the code to start the java proces: Win32::Process::Create($ProcessObj, ...
4
by: =?Utf-8?B?U3VyZXNoIE5hZ2FyYWphbg==?= | last post by:
Hello, I am trying to execute an application on a remote system. After checking several of the website I was managed to write a C# application do the same. But I am not able to track the Exit...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.