RE: [Ssh-sftp-perl-users] How to stop "error conditions" from terminating a script.
Brought to you by:
dbrobins
From: Mark A. F. <mar...@ea...> - 2005-05-31 15:55:12
|
From: Mark Allen <mar...@sh...> > > eval { > $sftp = 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. 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 |