How do I redirect stdout from system/execlp calls?

Discussion in 'C++' started by Paul Nilsson, Oct 3, 2003.

  1. Paul Nilsson

    Paul Nilsson Guest

    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
     
    Paul Nilsson, Oct 3, 2003
    #1
    1. Advertising

  2. Paul Nilsson

    WW Guest

    Paul Nilsson wrote:
    > 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

    --
    WW aka Attila
     
    WW, Oct 3, 2003
    #2
    1. Advertising

  3. Paul Nilsson

    tom_usenet Guest

    On Fri, 3 Oct 2003 18:38:53 +0200, "Paul Nilsson"
    <> wrote:

    >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
     
    tom_usenet, Oct 3, 2003
    #3
  4. Paul Nilsson

    Jerry Coffin Guest

    In article <blk8nu$bu$>, says...
    > 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.

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.
     
    Jerry Coffin, Oct 5, 2003
    #4
  5. Paul Nilsson

    Paul Nilsson Guest

    "Jerry Coffin" <> wrote in message
    news:...
    > In article <blk8nu$bu$>, says...
    > > 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.


    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

    >
    > --
    > Later,
    > Jerry.
    >
    > The universe is a figment of its own imagination.
     
    Paul Nilsson, Oct 6, 2003
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Erik S. Bartul

    execlp() - mystery arg

    Erik S. Bartul, Feb 16, 2004, in forum: C Programming
    Replies:
    6
    Views:
    758
    CBFalconer
    Feb 17, 2004
  2. Birch
    Replies:
    3
    Views:
    1,045
    Birch
    Oct 21, 2003
  3. Replies:
    4
    Views:
    605
    Malcolm McLean
    Jun 10, 2007
  4. Jim Freeze
    Replies:
    9
    Views:
    252
    Jim Freeze
    Feb 25, 2005
  5. Damphyr
    Replies:
    2
    Views:
    227
    Damphyr
    Dec 8, 2005
Loading...

Share This Page