Is there any reason not to use the complete expect to run this? The PERL module is not a fully implementation of expect as far as I know. I recall from Don Libes book ( the writer of expect) that there is excellent handling of exceptions you speak of in native expect.
I'd be interested to give this some more thought as I use native expect in a PERL shop. I have been thinking of using the module, but found that Expect is a complete language!
in reply to Re^2: My Perl/Expect script aborts when sftp connection stalls at remote destination
in thread My Perl/Expect script aborts when sftp connection stalls at remote destination