How do I redirect stdout from system/execlp calls?

P

Paul Nilsson

Hi,

Does anyone know how to redirect text output when issuing a system or an
execlp call? I have a GUI that insists on opening up a console whenever I
give a system function call, and I would like to redirect the text output to
a char buffer instead.

Paul
 
W

WW

Paul said:
Hi,

Does anyone know how to redirect text output when issuing a system

system("a command with output redirected");
or an execlp call?

There is no execlp in standard C++: http://www.slack.net/~shiva/welcome.txt
I have a GUI that insists on opening up a console
whenever I give a system function call, and I would like to redirect
the text output to a char buffer instead.

It will possibly still open a console. You will need to post your question
to a newsgroup dedicated to your platform/compiler:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9
 
T

tom_usenet

Hi,

Does anyone know how to redirect text output when issuing a system or an
execlp call? I have a GUI that insists on opening up a console whenever I
give a system function call, and I would like to redirect the text output to
a char buffer instead.

comp.unix.programmer might be a better place to ask, since standard
C++ has no methods to interact with consoles or any way to launch
processes other than "system".

Tom
 
J

Jerry Coffin

Hi,

Does anyone know how to redirect text output when issuing a system or an
execlp call? I have a GUI that insists on opening up a console whenever I
give a system function call, and I would like to redirect the text output to
a char buffer instead.

Find a newsgroup devoted to the OS you're using, and ask them about
popen -- it's likely to be available, and if it's not, there are at
least likely to be some people who will recognize the name and know what
to advise as an alternative.
 
P

Paul Nilsson

Jerry Coffin said:
Find a newsgroup devoted to the OS you're using, and ask them about
popen -- it's likely to be available, and if it's not, there are at
least likely to be some people who will recognize the name and know what
to advise as an alternative.

Hi,

Thanks, aparently this only works for console applications. However, the
MSVC++7 documentation for the popen function links to a document showing how
to do with a windows application as well! So you helped me anyway! Thanks,
Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top