nimdokk has asked for the wisdom of the Perl Monks concerning the following question:
Example of code in question:
open (STDOUT, ">$log_dir/$process.log") or exit 1; open (STDERR, ">&STDOUT") or exit 2; flock(STDOUT, LOCK_EX | LOCK_NB) or exit 3; truncate STDOUT, 0; #clear out STDOUT to start with a fresh log file. print "This is my log file.\n"; qx!someprogramtorun!; (do some more stuff) __DATA__ (what I see in the log file) This is my log file.
With the older version, I would also have captured the output from qx!someprogramtorun!. However, that is not being captured when run under Perl 5.8.0. Now, this is not a big problem for most external programs we use, but it causes one that we run to error out for some inexplicable reason. If I capture STDOUT and STDERR to a log file from the commandline with something like: my_program.pl >log.t 2>&1, everything runs perfectly. I capture both those lines that I want printed and anything incidental that the external programs throw out. I'm sure that what I am doing is not ideal, but it was working. I'd prefer not to have to do all the commandline redirections if it can be avoided. What am I missing? As far as I can determine, the output from qx!! is the only thing effected. I can't determine if the problem is with how I'm redirecting STDOUT and STDERR with open() or what.
Thanks in advance.
update: added line into code example to indicate that I need to retain control of the program after the qx!!.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem dup'ing STDOUT
by Thelonius (Priest) on Nov 26, 2003 at 18:40 UTC | |
|
Re: Problem dup'ing STDOUT
by holo (Monk) on Nov 26, 2003 at 16:41 UTC | |
by nimdokk (Vicar) on Nov 26, 2003 at 16:48 UTC | |
by holo (Monk) on Nov 26, 2003 at 16:58 UTC | |
by Joost (Canon) on Nov 26, 2003 at 17:40 UTC | |
by nimdokk (Vicar) on Nov 26, 2003 at 17:48 UTC | |
by Joost (Canon) on Nov 26, 2003 at 18:05 UTC | |
|