473,320 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Read stdout from another program

I am trying to read the standard out of another program into an array or string in my C++ program. I need to read each line individually because based on the output depends on what the program will do.

Example output of the other program is:
www.thescripts.com|/|192.168.1.10|75.126.163.34|37281|80|1
www.thescripts.com|/forum/forum129.html|192.168.1.10|75.126.163.34|36804|80| 1

As you can see the data is separated by a "|"(pipe).

I've been able to get this working in perl, however I need to be able to port it to C++. I've tried and tried but haven't made much success. Any direction would be great.

Also, I'm doing this in Linux... my goal is to use as portable code as possible... system() does not work as it waits for the command to complete before allowing the program to continue...

Thanks,
Jason Bush
Jul 5 '07 #1
2 6855
gpraghuram
1,275 Expert 1GB
I am trying to read the standard out of another program into an array or string in my C++ program. I need to read each line individually because based on the output depends on what the program will do.

Example output of the other program is:
www.thescripts.com|/|192.168.1.10|75.126.163.34|37281|80|1
www.thescripts.com|/forum/forum129.html|192.168.1.10|75.126.163.34|36804|80| 1

As you can see the data is separated by a "|"(pipe).

I've been able to get this working in perl, however I need to be able to port it to C++. I've tried and tried but haven't made much success. Any direction would be great.

Also, I'm doing this in Linux... my goal is to use as portable code as possible... system() does not work as it waits for the command to complete before allowing the program to continue...

Thanks,
Jason Bush

What is understood is
you have a program a.exe(for example)
and you have another program b.exe
you want to read the output of a.exe inside your b.exe?right
if yes then you can use
a.exe | b.exe
If this is not you wanted thengive me more explanation

Raghuram
Jul 5 '07 #2
You are correct. My program (b) would read from the standard out of another program (a). The pipe will work for what I'm doing, I was incorrect in assuming that piping like this did not work in Windows. Since it works in both operating systems, this will work for me! Thanks.

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true
Jul 5 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: mhenry1384 | last post by:
I am trying to run a program and filter the output on Windows XP. Since I want to filter the output, I'd like to read it a line at a time and only print the lines I care about. p =...
1
by: Jacek Pop³awski | last post by:
Popen from subprocess module gives me access to stdout, so I can read it. Problem is, that I don't know how much data is available... How can I read it without blocking my program? example:...
8
by: John Forkosh | last post by:
I have a C program that writes binary output to stdout, which works fine in Unix/Linux. But when someone else compiled and ran it in Windows, every time the program emitted a 0x0A, Windows...
0
by: Taran | last post by:
I am having this issue with both Visual C++ 6.0 and Visual Studio 2005 Beta 2. I have the SDK and DDK installed. I am trying to write a program to retrieve the EDID for a specific monitor in a...
9
by: Adi | last post by:
Hello eveyone, I wanna ask a very simple question here (as it was quite disturbing me for a long time.) My problem is to read a file line by line. I've tried following implementations but still...
8
by: Paul Edwards | last post by:
Is it permissible in C89 to do an "fclose(stdout)" and then exit, or is the C runtime library allowed to assume that stdout remains open and thus unconditionally do an fclose itself? Thanks. ...
20
by: David Mathog | last post by:
A program of mine writes to a tape unit. Output can be either through stdout or through a file opened with fopen(). When all the data is transferred to tape the program needs to close the output...
8
by: dmoore | last post by:
Hi folks, I've seen the following issue come up in multiple posts to this mailing list: I have a python program that spawns a child process with popen or popen2 or popen3 or popen2.popen2...
1
by: NeoGregorian | last post by:
Hello, I am writing a wrapper to a basic Input/Output programs (where you type a one line command at a time and then get 0 or more lines of output before you can input the next command). I'm...
13
by: rohit | last post by:
Hi All, I am new to C language.I want to read integers from a text file and want to do some operation in the main program.To be more specific I need to multiply each of these integers with another...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.