esolm has asked for the wisdom of the Perl Monks concerning the following question:

Anyone out there have problems with NET::ftp and zip files. The file keeps comming down corrupted - when I get the file using standard win2000 ftp cleint the file is ok. so the file is not the problem.

Any help would be appreciated.
#!/usr/bin/perl # file name here use warnings; use strict; use Net::FTP; use File::Copy "cp"; # ****************************************************** # SECTION 1 CHECK TO SEE IF THERE IS A NEW FILE ON JANUS # ****************************************************** # log into xxxxx with perl chdir "d:/cds_data/latest_download/"; my $ftp = Net::FTP->new("xxxxxxxxxx") or die "Couldn't connect: $@\n"; $ftp->login("xxxxxx", 'xxxxxxxx'); $ftp->cwd("/pushus/download"); $ftp->binary; $ftp->pasv; $ftp->get("download.zip"); $ftp->close; print "Th Th Tha That's All Folks!!!!!", "\n";

Replies are listed 'Best First'.
Re: Net::FTP and Zip files
by sachmet (Scribe) on Mar 19, 2001 at 12:11 UTC
    Funny...
    #!/usr/bin/perl use warnings; use strict; use Net::FTP; my $ftp = Net::FTP->new("ftp.cdrom.com") or die "Couldn't connect: $@\n"; $ftp->login("ftp", 'warez@'); $ftp->cwd("/.2/simtelnet/gnu/djgpp/v2/"); $ftp->binary; $ftp->pasv; $ftp->get("faq230s.zip"); $ftp->close; print "Th Th Tha That's All Folks!!!!!", "\n";
    (file chosen at random from simtelnet at cdrom)

    This works as expected, and the zip downloads fine, at least on a UNIX system. One other thing I'd try: place binmode() towards the top of the program; see how that fares. Perl may be converting your "\n" to "\r\n", which is not what you'd want.

    Further, check the return of $ftp->get for the filename and check the filesizes to see if they're identical. Also, make sure the file doesn't exist first on the local side, if at all possible.
Re: Net::FTP and Zip files
by Anonymous Monk on Mar 19, 2001 at 12:13 UTC
    Nevermind - its working!