I just can't seem to get a file from an FTP server using Net::FTP. I've got the latest version from CPAN. here's my code:
sub retrieve_file { my($file) = shift; my($site) = shift; my($user) = shift; my($pass) = shift; my($dir) = shift; my($params_ref) = shift; my($pwd) = (); my($retval) = 0; chomp($pwd = `/bin/pwd`); chdir($TOP_DIR); chdir($$params_ref{FILE_DIR}); my($ftp) = Net::FTP->new($site, Debug => 1) or warn_msg("retri +eve_file: couldn't start FTP session for $site: $!") && return 0; $ftp->login($user, $pass) or warn_msg("retrieve_file: couldn't + access $site: " . $ftp->message()) && return 0; $ftp->cwd($dir) or warn_msg("retrieve_file: couldn't access $d +ir on $site: " . $ftp->message()) && return 0; if ($file =~ /\//) { my(@dirs) = split(/\//,$file); foreach (@dirs) { if ($_ eq $dirs[$#dirs]) { $file = $_; last; } $ftp->cwd($_) or warn_msg("retrieve_file: coul +dn't access $_ on $site: " . $ftp->message()) && return 0; } } $ftp->binary(); $ftp->get($file, $file) or warn_msg("retrieve_file: couldn't g +et $file: " . $ftp->message()) && return 0; $ftp->quit; chdir($pwd); return 1; }
here's my error message: Net::FTP: Unexpected EOF on command channel at ./netpkg-client.pl line 84

Or, I get no error message, and simply nothing happens.
Is there something weird that I should be doing, like read'ing a filehandle? Or anything else? Or is Net::FTP just broken for me?


In reply to Net::FTP get problem (unexpected EOF) by theirpuppet

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.