I have a simple scenario. I upload a zip file on a disk to some server.


use Net::FTP; my $ftp = Net::FTP->new($server, Timeout=>1800, Passive=>1, Debug=>3); $ftp->login($user, $pswd); $ftp->cwd("files"); $ftp->binary(); $ftp->put("build.zip");

The put() succeeds 9 out of 10 times, but for the 10th time (and this is very random), it throws up.

This, I know is because of: 1. Server closing connection, or 2. Internet link break 3. Unknown

My question is what *really* tells me that put() has failed?

a. I have tried $ftp->message but this is empty.
b. $! as I know is not exactly the way, it tells me 'bad file descriptor'
c. I also used eval() with $ftp->message, but is empty as well

So what gives?


By the way, when I try this on a DOS prompt and stop the ftp server, this is what I get.

ftp bin
200 Type set to I
ftp mput build.zip
mput build.zip? y
200 Port command successful
150 Opening data channel for file transfer.
Netout :Software caused connection abort
421 Server is going offline
Connection closed by remote host.


Notice the last 3 lines, I know exactly what went wrong.
Your help is appreciated.


In reply to Perl Net::FTP put() gives little help on errors by amitsk

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.