DCPM: return values
Neil Williams
linux at codehelp.co.uk
Thu Jan 8 17:16:14 CST 2004
Is it as easy as it would appear to report a return value from a perl script
run from the command line?
I want to wrap a troublesome Perl script (you can all guess which project this
is for) in a bash script. (It'll become clear, don't fret.)
If returnvalue == 0, all OK, exit bash script.
If return value <> 1 - immediately re-run script.
Reasons:
It's a workaround for a bug in the module that leaves the module unstable on
refused connections (yes, it's my old friend Z39.50 again). There are two
critical data objects/addresses - a manager reference and a connection
handle. The manager reference can only be safely destroyed by calling the
connection handle with the close() method. The problem comes that $conn comes
back undefined in certain error states so I can't call $conn->close(); That
leaves the memory in a shambles and the next $mgr-> operation (of any kind)
leads to either a SIGPIPE or Illegal Seek. Handling the SIGPIPE isn't the
answer because the module is truly unstable at this point.
However, there is a LOT of work for this script to perform and I cannot afford
to let it just die() until the next cron slot comes around. When it DOES
work, it can take a max of 6 minutes to complete. To be safe, cron is set at
10 minutes. That leaves many times when it's bombed out after 30 seconds and
there's no activity.
The die() handler currently drops me back to a last; statement and the MySQL
connection is then closed.
Can I just use return $errno; and expect bash to pick it up? Well, no:
$ perl -e 'return 1;'
Can't return outside a subroutine
I haven't done a lot of conditional bash scripts - what is the best way to do
it?
--
Neil Williams
=============
http://www.codehelp.co.uk/
http://www.dclug.org.uk/
http://www.isbn.org.uk/
http://sourceforge.net/projects/isbnsearch/
http://www.biglumber.com/x/web?qs=0x8801094A28BCB3E3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
Url : http://mail.pm.org/archives/devoncornwall-pm/attachments/20040108/e14ff920/attachment.bin
More information about the Devoncornwall-pm
mailing list