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! | [reply] |
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
| [reply] |
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.
| [reply] [d/l] [select] |
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.
| [reply] [d/l] |
Excellent! Using /dev/stdout and /dev/stderr did exactly what I needed it to do.
Thank you!
| [reply] |