theirpuppet has asked for the wisdom of the Perl Monks concerning the following question:
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:
here's my error message: Net::FTP: Unexpected EOF on command channel at ./netpkg-client.pl line 84sub 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; }
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?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Net::FTP get problem
by rob_au (Abbot) on Jun 18, 2002 at 06:48 UTC | |
Re: Net::FTP get problem (unexpected EOF)
by Anonymous Monk on Jan 29, 2004 at 18:43 UTC |
Back to
Seekers of Perl Wisdom