Thread: output of fping

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    8

    output of fping

    I'm trying to parse the output of fping in my program, but the second line of the output, is always going directly to my standard output. So if the output of fping is:

    x.x.x.x : [0], 84 bytes, 1.98 ms (1.98 avg, 0% loss)

    x.x.x.x : xmt/rcv/%loss = 1/1/0%, min/avg/max = 1.98/1.98/1.98

    then I'm not able to read this second line in my program.

    My code looks like this:

    Code:
    M_fp = popen("fping -c 1 -t2000 x.x.x.x","r");
    fread(buffer,1, 1000, M_fp);
    So the first line will be in my buffer and the second line is shown in my shell.

    How can I get both lines in the buffer, or at least make that the second line is not shown in the buffer?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Try at the command line
    fping -c 1 -t2000 x.x.x.x 1>stdout.txt 2>stderr.txt

    If you get output in both files, then you need something better than popen (or a better command line sent to popen).

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    8
    OK, that helped me out. Thx a lot.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. code output...
    By roaan in forum C Programming
    Replies: 6
    Last Post: 07-03-2009, 02:22 AM
  2. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 03:08 PM
  3. Replies: 4
    Last Post: 11-30-2005, 04:44 PM
  4. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  5. Output problems with structures
    By Gkitty in forum C Programming
    Replies: 1
    Last Post: 12-16-2002, 05:27 AM