[Chicago-talk] testing exit status of external program

Jeremy Hubble jhubble at core.com
Tue Dec 9 13:16:17 CST 2003


Sometimes the result may need a little TLC.  I have worked with some 
apps (particularly Interwon's) where the result would have to be 
shifted 8 bits to get the 'real' return code.  [I am not sure if this 
was due to something the app was doing, or if it was a perl issue.) 
Also, certain older versions of perl (in particular on AIX) did not 
have the return code available via $? when the perl process was spawned 
from another process.

But with something simple like the code fragment, $? should be fine.

Jeremy

> $?.
> 
> close (ES_CLIENT);
> print "ES_CLIENT returned $?";
> 
> (incidentally, I didn't remember the variable name, I
> just did a 'perldoc -f close' and got lucky)
> 
> -Jim......
> 
> --- "Dooley, Michael" <Dooley.Michael at con-way.com>
> wrote:
> > If I have a program like below how can I test the
> > return value of the
> > external program?
> > 
> > open (FILE, "./test.file");
> > open (ES_CLIENT, "|shell_program");
> > while (<FILE>) {
> > print ES_CLIENT $_;"\n";
> > }
> > close (ES_CLIENT);
> > close (FILE);
> > 
> > [qgatu003]/export/home/mxdooley/mbi_script$cat
> > test.file |shell_program
> > 16:06:32: info: broker_path=qgatu003
> > 16:06:32: warning: connect=10.40.11.28:9701
> > (Connection refused, tcp)
> > 16:06:33: warning:
> > broker_malfunction=10.40.11.28:9701
> > (reason=no_broker_reply, service=brokerService)
> > 16:07:02: fatal:
> > unable_to_resolve_or_connect_to_sclient=ES_MSGIN_RR
> > 
> > [qgatu003]/export/home/mxdooley/mbi_script$print $?
> > 1
> > _______________________________________________
> > Chicago-talk mailing list
> > Chicago-talk at mail.pm.org
> > http://mail.pm.org/mailman/listinfo/chicago-talk
> 
> 
> __________________________________
> Do you Yahoo!?
> New Yahoo! Photos - easier uploading and sharing.
> http://photos.yahoo.com/
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at mail.pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
> 






More information about the Chicago-talk mailing list