Capture system call output?

This is a discussion on Capture system call output? within the C Programming forums, part of the General Programming Boards category; I want to be able to call something like "wc -l file.c" and pipe that information back into the program ...

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    13

    Capture system call output?

    I want to be able to call something like "wc -l file.c" and pipe that information back into the program I'm running. I've googled and found some information on popen, but that doesn't seem to help any. I've tried to consider some redirecting or piping but to no avail. Any ideas?

    Thanks in advance

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,801
    Well, I was going to suggest popen... how were you using it? Maybe there was something off. Could you post what you did try?
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    13
    Quote Originally Posted by hk_mp5kpdw View Post
    Well, I was going to suggest popen... how were you using it? Maybe there was something off. Could you post what you did try?
    Honestly, I didn't "try" it. I was looking at the man page:

    FILE *popen(const char *command, const char *type);

    .........

    Ok this is the point where I smile like an idiot and walk away. I went with your advice and tried it. Worked perfectly.

    Thanks again

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Capture output of spawned ftp program?
    By chuck_tx in forum C Programming
    Replies: 2
    Last Post: 10-07-2009, 09:22 AM
  2. System Call Table
    By NuNn in forum C Programming
    Replies: 3
    Last Post: 03-26-2009, 01:56 PM
  3. Replies: 2
    Last Post: 03-05-2009, 09:25 AM
  4. temperature sensors
    By danko in forum C Programming
    Replies: 22
    Last Post: 07-10-2007, 07:26 PM
  5. Pls help me to do this project in C I need source code
    By sureshmenon74 in forum C Programming
    Replies: 4
    Last Post: 10-04-2001, 06:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21