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.


In reply to Net::FTP Question. by FeistyLemur

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.