Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Catching STDERR with open (

by rbc (Curate)
on Mar 11, 2002 at 22:53 UTC ( [id://151003]=perlquestion: print w/replies, xml ) Need Help??

rbc has asked for the wisdom of the Perl Monks concerning the following question:

Dears Monks,

I could use some help.
I am executing sqlldr from a perl script like so ...
my $cmd = "sqlldr userid=xyz/xyz@xyz control=myfile.ctl"; if( OUT, open( "$cmd|" ) ) { while(<OUT>) { if (/'error'/i) { print "Holy balony! The server is down Batman!"; ... } else { print $_; } } }

The problem I am have is that the database is down
but my script does not realize that because all I
see is the STDOUT ... I assume.

How can I get the STDERR output so I can search for
/'error'/ ?

Replies are listed 'Best First'.
Re: Catching STDERR with open (
by cjf (Parson) on Mar 11, 2002 at 23:19 UTC
Re: Catching STDERR with open (
by particle (Vicar) on Mar 12, 2002 at 01:53 UTC
    if you wish to keep the streams seperate, you might want to look at this recent node: IPC::Open3 woes

    ~Particle ;Þ

Re: Catching STDERR with open (
by pizza_milkshake (Monk) on Mar 12, 2002 at 03:41 UTC
    couldn't you just run the script with &2>err.tmp and just search err.tmp? i'll learn this unix thing yet.

    perl -e'@a=split//," \n/)\"={\"";print $a[$_] for split//,"00002731000223155264555102401"'
Re: Catching STDERR with open (
by jepri (Parson) on Mar 12, 2002 at 12:10 UTC
    And follwoing pizza_milkshake's line of thinking, you could try "command stuff 2>&1 |" which will combine STDERR and STDOUT.

    ____________________
    Jeremy
    I didn't believe in evil until I dated it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://151003]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-19 18:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found