tags:

views:

37

answers:

2

Hi, please, is it possible to catch output from concole program? I would like to write GUI to console app, but I need to get its output.

+3  A: 

If the program's output is using standard out or standard error, you can use shell redirection to redirect the program output to a file (which your GUI can read). For example:

console_app.exe >stdout.log 2>stderr.log

If you want to read the program's output in realtime (while it is running), you will need to give some more details about your GUI program. What language(s) are you using? What operating system(s)?

bta
A: 

If you want to capture the output as the command line process runs, you want to use the Windows API function CreateProcess(). You would basically create a 'pipe' for the output and assign its handle to stdout. You'd then read from it as if it was a file while the command line program runs.

The exact implementation of how this is done will depend on what language you are using. You left that out of your question.

GrandmasterB
I like your option, I use pure C. I found function prototype, so I hope I can get it done from this point. Thanks.
B.Gen.Jack.O.Neill
Glad I could help!
GrandmasterB