in reply to Re: redirecting output to STDERR and STDOUT
in thread redirecting output to STDERR and STDOUT

Thank you all for your help. Having researched this program a little further, I'm afraid that what actually needs to be done is a change to a program written in C which is called by the .pm that the perlscript I'm working in calls. It just doesn't appear that the C program allowed for this possibility. Blame it on poor planning I guess. Anyway, thank you all for some excellent responses!
  • Comment on Re^2: redirecting output to STDERR and STDOUT

Replies are listed 'Best First'.
Re^3: redirecting output to STDERR and STDOUT
by zentara (Cardinal) on Feb 22, 2005 at 19:40 UTC
    If you are calling a C program, and need to separate and direct your STDOUT and STDERR, you might be able to do it with the IPC::Open3 module. Just an idea.

    I'm not really a human, but I play one on earth. flash japh
Re^3: redirecting output to STDERR and STDOUT
by djp (Hermit) on Feb 23, 2005 at 02:53 UTC
    On Solaris and Linux /dev/stdin, /dev/stdout, and /dev/stderr are device names for standard input, standard output, and standard error. /dev/stdin is occasionally useful when piping data to a recaltricant C program which doesn't read from standard input or recognise '-' as a synonym for standard input. Likewise for the others. In your case you would set $logfile = "/dev/stderr"; of course this will only help you if your OS supports /dev/stderr. /dev/fd/2 might be another option for standard error. On Solaris, man -s 4 fd for details.
      Excellent! Using /dev/stdout and /dev/stderr did exactly what I needed it to do. Thank you!

      I can confirm that /dev/stdin and friends work on Linux.

      If you are on an otherwise unixy system that does not have these, you should be able to create a FIFO (a.k.a. named pipe) for each stream, spawn child processes to pipe them to STDOUT and STDERR, and hand the FIFO names to C. See "Named Pipes" in perlipc.