execlp output to file

This is a discussion on execlp output to file within the C Programming forums, part of the General Programming Boards category; Is there a way to get the output from running another command via execlp to output to a file? Right ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    23

    execlp output to file

    Is there a way to get the output from running another command via execlp to output to a file?

    Right now I am experimenting with fopen but I can't figure out what to do..

    Any suggestions?

    Thank you

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    In the child process, just before the execl call

    int fd = open( "file", O_WRONLY );
    close( 1 );
    dup( fd );
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM
  2. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  3. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM
  4. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 02:58 PM
  5. Simple File Creation Algorithm
    By muffin in forum C Programming
    Replies: 13
    Last Post: 08-24-2001, 03:28 PM

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