RE: Backquote & STDERR
by Wechsler, Steven other posts by this author
Sep 26 2000 8:40AM messages near this date
Re: How to get the standard output of a child process on a file ?
|
Perl DBI&DBD-Oracle Problem after ISS 3.0-4.0 upgrade
Scott, don't know if you got a response to this yet, but try:
@array = `$cmd 2> &1`;
Your original statement would have redirected STDERR to a file named "1". A
better method would be to redirect STDERR within the Perl script. The Camel
book has a good example of this. I'd also recommend redirecting STDERR to a
different destination than STDOUT if you're trying to parse it, otherwise
the two will become intertwined and you won't be able to tell which is
which.
Steve
--
Steve Wechsler/Application Manager/Wall St. Access
Steven.Wechsler@[...].com
"There is no reason anyone would want a computer in their home."
-- Ken Olson, president, chairman and founder of DEC, 1977
Support Anti-Spam legislation: http://www.cauce.org
> -----Original Message-----
> From: Scott.Fleming@[...].com [mailto:Scott.Fleming@[...].com]
> Sent: Monday, September 25, 2000 1:45 PM
> To: activeperl@[...].com
> Subject: Backquote & STDERR
>
>
> Does anyone know how I can get STDERR back to a variable in my perl
> program? I am running a system command in backquotes and need
> to interogate
> STDERR to determine if it has worked or not.
>
> I have tried the following......
>
> @array = `$cmd 2>1`;
>
> where $cmd is the command I want to run. It appears to partly
> work. If I
> omit the 2>1 I see the STDERR on my screen and with it I do
> not see the
> error message. In both cases however @array only contains the
> STDOUT data.
>
> I could always pipe the output of the command to grep and
> search for the
> error text but I was looking for a way to do it in Perl.
>
> Any help would be appreciated.
>
> Thanks.
>
> _______________________________________________
> ActivePerl mailing list
> ActivePerl@[...].com
> http://listserv.ActiveState.com/mailman/listinfo/activeperl
>
|