in reply to Test whether STDOUT is connected to a file
rovf:
I think that the problem you're having is that the perl executable doesn't manage I/O redirection. Normally that's handled by the shell. So the command you're giving doesn't actually try to redirect STDOUT and STDERR--instead it's just passing ">out.txt" and "2>&1" as arguments to the myProg.pl script.
Why not simply add command-line options to myProg.pl to have alternate output streams? Then you don't have to detect redirection--you just tell myProg where to send the output.
...roboticus
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Test whether STDOUT is connected to a file
by rovf (Priest) on Aug 18, 2010 at 14:20 UTC | |
|
Re^2: Test whether STDOUT is connected to a file
by rovf (Priest) on Aug 18, 2010 at 13:48 UTC |