Re: [Ssh-sftp-perl-users] Can I test for connection reset and also supress warnings
Brought to you by:
dbrobins
From: Steve C. <st...@oc...> - 2008-07-30 20:48:55
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> Heiko Jansen wrote: <blockquote cite="mid:121...@tr..." type="cite"> <pre wrap="">Am Dienstag, den 29.07.2008, 13:54 -0400 schrieb Steve Comrie: </pre> <blockquote type="cite"> <pre wrap="">First, it would appear as though my clients SFTP server is occasionally reseting (or dropping) the connection. When this happens my automated transfer script completely dies with a closing connection message. Is it possible for me to trap this error (or test whether or not my $sftp object is connected) and have the script reconnect to the server to resume transfer? </pre> </blockquote> <pre wrap=""><!----> You should be able to wrap the problematic method call with an "eval" and have a look at $@ afterwards. And according to the Net::SFTP perldoc there ist the status() method to find out if something nasty happened after you called any of the other methods except from new(). </pre> </blockquote> I could give that a shot, but it appears that there isn't one particular "problematic" method call. It's just when the remote server disconnects me, the entire script goes ends with an error. It could be right in the middle of a file transfer. It I wrapped the entire thing in an eval block, it would be a bit of a pain to try and figure out where in my nested loop I was when the connection dropped and would most likely have to just start the entire process over again.<br> <br> Which is sort of what I've resorted to doing, I was just hoping there was a way to have Net::SFTP tell me when it dropped connection as opposed to just "dying".<br> <blockquote cite="mid:121...@tr..." type="cite"> <blockquote type="cite"> <pre wrap="">And secondly, the less important issue... my clients server doesn't allow me to fsetstat which doesn't appear to be a problem at all, but the script is outputting a large number of "Couldn't fsetstat: Operation unsupported" messages. I'd like to disable only that message if possible as it's not entirely useful while other error messages & warnings are. </pre> </blockquote> <pre wrap=""><!----> As far as I know, you cannot disable one specific warning - but you can pass a sub ref as argument "warn" to the new() method in which you can then decide what to do with the warnings you receive. See the perldoc for more info</pre> </blockquote> Do you know if there is a simple way to prevent attempting to perform fsetstat on a put?<br> <br> Thanks again .. <br> <br> ---<br> Steve Comrie<br> </body> </html> |