RE: [Ssh-sftp-perl-users] How to stop "error conditions" from terminating a script.
Brought to you by:
dbrobins
|
From: Mark A. <mar...@sh...> - 2005-05-31 16:50:11
|
Yes, you're right, that would be a better way to handle $@.
Actually, Jim sent me a little code snippet in a private mail which
implements the script's eval block in the fashion you suggest.
Cheers,
--Mark=20
-----Original Message-----
From: Mark A. Fuller [mailto:mar...@ea...]=20
Sent: Tuesday, May 31, 2005 10:55 AM
To: Mark Allen; Jim Lane; ssh...@li...
Subject: RE: [Ssh-sftp-perl-users] How to stop "error conditions" from
terminating a script.
From: Mark Allen <mar...@sh...>
>
> eval { =20
> $sftp =3D Net::SFTP->new($host,%args);
> };
> if ( $@ ) {
> warn "sftp error: $@\n";
> # get next host
> }
For what it's worth: a couple years ago I thought I saw a condition
where multiple failures occured within the eval. I couldn't count on $@
containing the pertinent (meaningful) text for the failure. That's why
the eval examples I posted back then included a signal catcher within
the eval to capture the $@ text and add it to an array. After the eval,
I could test if my array contained > 0 entries and emit all the entries
in my warn output.=20
Maybe the maintainer can comment on whether that's possible. But, I
definitely remember a situation where something like a put/get was
failing and I was not getting the real message in $@. Getting control on
die and capturing $@ into an array indicated it died multiple times and
the first time was the one that had the meaningful message.
Hope that helps,
Mark
|