Itatsumaki has asked for the wisdom of the Perl Monks concerning the following question:
I found a piece of old code that I had written that goes to an FTP site and retrieves a file via LWP::Simple:
my $data = get('ftp://ftp.ncbi.nih.gov/refseq/LocusLink/LL_tmpl.gz') +; my $outfile = '>GO_TERMS.CSV'; if (!$data) { exit(); } open(OUT, '>LL_tmpl.gz'); binmode OUT; print OUT $data; close(OUT);
I thought: hey, that's silly because it loads the whole file into a variable. Why not rewrite it with Net::FTP? That should be shorter, clearer code, as well as much faster.
use Net::FTP; my $ftp = Net::FTP->new('ftp.ncbi.nih.gov', Debug=>0); $ftp->login('anonymous', 'anon@anon.com'); $ftp->cwd('/refseq/LocusLink/'); $ftp->type('binary'); $ftp->get('LL_tmpl.gz'); $ftp->quit();
The problem is, when I run the file downloaded via Net::FTP through a gzip -t it indicates a corrupt archive. When I get it from LWP::Simple, the archive seems valid. I've reproduced this on a couple of machines, but they are all behind the same router: can anyone validate this from other machines? Any ideas what's causing the FTP download to be invalid?
-Tats
Update: Warning! The downloaded file is rather large ~30 MB. (thanks for point it out b10m)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Unable to complete download with Net::FTP
by holo (Monk) on Nov 28, 2003 at 22:00 UTC | |
by Itatsumaki (Friar) on Nov 28, 2003 at 22:11 UTC | |
Re: Unable to complete download with Net::FTP
by bart (Canon) on Nov 29, 2003 at 00:47 UTC | |
by Itatsumaki (Friar) on Nov 29, 2003 at 06:45 UTC | |
by davis (Vicar) on Nov 29, 2003 at 13:04 UTC | |
by Itatsumaki (Friar) on Dec 01, 2003 at 07:37 UTC | |
by Itatsumaki (Friar) on Dec 01, 2003 at 07:35 UTC | |
Re: Unable to complete download with Net::FTP
by pg (Canon) on Nov 28, 2003 at 21:58 UTC | |
by Itatsumaki (Friar) on Nov 28, 2003 at 22:04 UTC | |
by b10m (Vicar) on Nov 28, 2003 at 22:19 UTC |