OK, I want to redirect all the STDOUT of a system( cmd ) to
a log file.
Now I know you are saying, "Hey thats simple, just use a
redirection metacaracter in the system() call, like
system( cmd > /dir/logFile).", but what if your system
doesn't support those shell metacaracter???????
It seems that you should be able to redefine the default
STDOUT, STDIN, STDERR definitions that are inherited by the
system() call, but
open( LOG, /dir/logFile);
*STDOUT = *LOG;
*STDERR = *LOG;
print "This is STDOUT";
print STDERR "This is STDERR";
system( "dir" );
still allows the dir's OUT and ERR to go to the terminal
while the print "This is STDOUT"; and
print STDERR "This is STDERR";
go to the LOG file.
Any Perl Gurus out there????
a log file.
Now I know you are saying, "Hey thats simple, just use a
redirection metacaracter in the system() call, like
system( cmd > /dir/logFile).", but what if your system
doesn't support those shell metacaracter???????
It seems that you should be able to redefine the default
STDOUT, STDIN, STDERR definitions that are inherited by the
system() call, but
open( LOG, /dir/logFile);
*STDOUT = *LOG;
*STDERR = *LOG;
print "This is STDOUT";
print STDERR "This is STDERR";
system( "dir" );
still allows the dir's OUT and ERR to go to the terminal
while the print "This is STDOUT"; and
print STDERR "This is STDERR";
go to the LOG file.
Any Perl Gurus out there????