[sf-perl] opening a pipe to a system command

Herb Rubin herbr at pfinders.com
Thu Jul 20 11:31:58 PDT 2006


Peter,

If I remember correctly, the system command sets the $? variable with the return code.

So, you have access to it. I also remember that you have to do some bitwise operation to get the numeric value properly from the return code. Then there's the issue of Perl on Windows compatibility...

Here's an interesting web page for you:

http://aspn.activestate.com/ASPN/Mail/Message/perl-unix-users/2073142

Herb Rubin


----- Original Message -----
From: Peter # PHX Loo <Peter.Loo at source.wolterskluwer.com>
To: sfpug at sf.pm.org
Sent: Thursday, July 20, 2006 10:31:21 AM GMT-0800
Subject: [sf-perl] opening a pipe to a system command


Hi, 

Would someone happen to know how I can trap an error return from the pipe? Here is what I am doing. 

unless(open(SYSCMD, "| someSystemCommand -d someFlag -u moreFlag1 -w moreFlag2")) { 
DO SOME ERROR HANDLING... 
} 

I tried eval {}; also and nothing was trapped. 

Hope someone has an answer for this. :) 

Thanks. 

Peter Loo 




More information about the SanFrancisco-pm mailing list