On Thursday, August 8, 2002, at 02:29 , Sylvanie, Jean-Pierre wrote:
> Hi guys,
>
> Actually I want to get STDERR ouput to have more details about systems
> call
> errors, and write the result to a log file...
[..]
> my $cmd = "$ZIP_CMD $filename";
>
> if ( system($cmd) != 0 ){
> chomp(@err = <GET_STDERR>);
> log_("0310E-Can't zip file Cmd=[$cmd]; stderr=[".join("; ",@err)."]
> ");
> }
this is where you may want to deal with the
alternative strategy and not use 'system' -
if you really want to cope with the information
that comes back from $cmd
I prefer the classic 'popen()' strategy perl offers
Hence I make sure that the stderr is attached to stdout
of the $cmd - so that it comes back into me with the
classic 2>&1 notation...
open(CMD, "$cmd 2>&1 |")
or die "unable to open $cmd :$!\n"
while(<CMD>) {
#
# if it would only send stuff on stderr then
# you only have to grot it out - otherwise you
# can also grot out the stdout stuff
#
}
close(CMD) or deal_with_error_case($cmd);
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]