Computing.Net > Forums > Programming > Capturing DOS output in C++

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Capturing DOS output in C++

Reply to Message Icon

Original Message
Name: Scott
Date: December 27, 2001 at 11:50:58 Pacific
Subject: Capturing DOS output in C++
Comment:

Does anyone know how to get the output of a DOS program in C++. I have an old program that I use in DOS and I need to get the data it outputs, but I havn't found a good way to do it yet. So if anyone knows please let me know


Report Offensive Message For Removal


Response Number 1
Name: Xeon
Date: December 27, 2001 at 15:45:08 Pacific
Reply: (edit)

Dunno if this helps. Can you manage to redirect STDOUT to your program? I think the stream libs supports this. Again, it's only a suggestion. I'm not too familiar with C++.


Report Offensive Follow Up For Removal

Response Number 2
Name: Richard
Date: December 29, 2001 at 08:19:23 Pacific
Reply: (edit)

Hi Scott
Just a thought
The dos program that you are trying to pick up the output from
Is it a program that you have writted ?
Is it possable to redirect the output to a file ?
e.g > text.doc

or does the information get displayed on the screen from within the program ?

if it is posble to re-drect the output to a file you may be able to read this information into the c++ program as normal

hope it helps

regards
Richard


Report Offensive Follow Up For Removal

Response Number 3
Name: Scott
Date: December 30, 2001 at 18:52:41 Pacific
Reply: (edit)

The program is not one that I have written. It displays the information on the screen as part of the program. When I call my program and it runs the dos program it will not let me capture the output using a cin command. After the dos program I get my prompt for input in my program. So I am wondering if there is a screen capture command that would read the screen and put it into some sort of string, from which I could get the needed information
Scott


Report Offensive Follow Up For Removal

Response Number 4
Name: MacGyver
Date: January 13, 2002 at 09:55:35 Pacific
Reply: (edit)

No, what the other guy meant was just do this at the dos prompt:

program.exe >>log.txt

just replace the program.exe with the name of the program you run, it will pipe the output to log.txt. use just > to make a new log.txt everytime.


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you own an iPhone?

Yes
No, but soon
No


View Results

Poll Finishes In 7 Days.
Discuss in The Lounge
Poll History




Data Recovery Software