FeistyLemur has asked for the wisdom of the Perl Monks concerning the following question:
Everything I've read about Net::FTP leads me to believe what I'm doing with it should be correct, but it clearly is not, as I'm getting one exception that kills my entire script in specific conditions.
I'm connecting to a series of devices via ftp to upload and burn a firmware file. In some rare instances, the FTP connection could be successfully established, and upload of the file can begin, but then the device could lose connectivity or simply time out the process.
The documentation says do this...
my $user='user'; my $password='pass'; my $file='/path/file'; my $ftp=Net::FTP->new($client, Timeout => 30, Passive => 1) or die "C +ould not Connect.\n"; $ftp->login ($user, $password); $ftp->binary; $ftp->put($file) or die "Error Uploading.\n"; $ftp->quit;
if connection is lost during the $ftp->put($file) or the device just pukes and it times out, the whole script pukes and drops a timeout error from the module itself. What am I doing wrong with how I'm doing this?
EDITED: Yes $pass was a typo only in the example above, corrected to $password. I do use strict and warnings and the code otherwise runs flawlessly other than the issue I very rarely have with timeouts.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::FTP Question.
by hippo (Archbishop) on Aug 13, 2015 at 18:07 UTC | |
by FeistyLemur (Acolyte) on Aug 13, 2015 at 18:25 UTC | |
|
Re: Net::FTP Question.
by runrig (Abbot) on Aug 13, 2015 at 18:25 UTC | |
|
Re: Net::FTP Question.
by stevieb (Canon) on Aug 13, 2015 at 19:26 UTC | |
by FeistyLemur (Acolyte) on Aug 13, 2015 at 19:49 UTC |