473,795 Members | 2,391 Online
Bytes | Software Development & Data Engineering Community
+ 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 1827
On Jul 14, 4:10 pm, dae3 <7252d...@examp le.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
2602
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
2965
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 first 5 fibonacci number. The problem is, I thought the parent process will always go first, and so here I should get "0, 1, 1, 2, 3" But I ran the program, it will give me "1, 2, 3, 0, 1", which is, the child process ran first. Is there any way...
2
3206
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 just continues as if nothing where wrong after process.Start is executed and I get an Exit code from the process
10
15918
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 that AcroComm will sometimes stop polling in the middle of the process and terminate. The programing manual for the app says that it sends a code to the operating system when it is done that tells what has happend like the following: 0 ...
4
20318
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 C:\temp\ConsoleApplication1\ConsoleApplication1\test1.bat: exit /B 6 Here is some C# code:
8
16166
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 achieve this using fork() and execv() API calls. but execv() method call is synchronous and does not return untill user closes the child application or a launch program error occurs.
1
5083
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 suggested in a faq, but it still doesnt seem to work. Below is what I have done: pid = fork() if (pid == 0){ printf ("http://my.wait.page"); exit (100);
0
1316
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 catching the ProcessExit event (this is a console app). The problem is that calling WriteToServer as seen below will immediately exit the program WITHOUT generating any exceptions or any other notices, including if I step through the code...
3
10372
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, shift(@args), join(" ", @args), 0, Win32::Process::NORMAL_PRIORITY_CLASS|Win32::Process::CREATE_NO_WINDOW|Win32::Process::DETACHED_PROCESS, $installPath) or $retCode = 99;
4
5495
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 Code of the application. The return value only tells me if the application started successfully. Is their a way to capture the final exit code of the application that is started remotely?
0
10438
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10214
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10164
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7540
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.