Thread: Capturing from stdout

  1. #1
    Former Member
    Join Date
    Oct 2001
    Posts
    955

    Capturing from stdout

    Wow, it HAS been a while since I last came in here! This place really IS different!... I could sit and say stories about this place , but I don't want to anyways.

    I want to make a program that spawns a second program, I actually want the first program to capture what the second one outputted to the screen. The code has to be completely ANSI compliant, since it's going to be written for windows, linux AND FreeBSD...

    Does anybody know how to do something like this?

    Chhers

    Oskilian

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > The code has to be completely ANSI compliant
    ANSI only gives you stdio, it doesn't say what happens on the other side of the stream.

    Next best bet is POSIX (which I think covers you)
    popen() allows you to run a process, and capture one of its stdio streams
    http://sdx1.uky.edu/cgi-bin/man.cgi?...ll&topic=popen

    Even then, its probably worth keeping the part of the code which does this in its own neat little corner to minimise porting problems.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Case Statement
    By danlee58 in forum C Programming
    Replies: 16
    Last Post: 11-23-2008, 08:46 PM
  2. Replies: 2
    Last Post: 07-12-2008, 12:00 PM
  3. Capturing stdout from a child process
    By zacs7 in forum Windows Programming
    Replies: 0
    Last Post: 08-07-2007, 01:44 AM
  4. forcing stdout of external program to be line-buffered
    By FreakCERS in forum C Programming
    Replies: 4
    Last Post: 09-17-2006, 12:46 PM
  5. Problems with switch()
    By duvernais28 in forum C Programming
    Replies: 13
    Last Post: 01-28-2005, 10:42 AM