FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 11th, 2003, 11:18 AM
alanlh alanlh is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 13 alanlh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Use Net::FTP download file has length error

Hi, guys, my question is:

I used Net::FTP in my script and try to download some zipped files from an ftp website. After downloading I need to unzip them. But the 'gunzip' always complain about those .gz files with "-CRC error" and "-Length error". So I checked the size of downloaded files and found they are several bytes shorter than they are supposed to be. Then I tried to ftp to the site and use 'get' command to download files one by one at the command line. This is successful and the length of files are good and files are unzipped correctly this time. Now I believe this is NOT a gunzip problem but a FTP problem. I don't know why FTP transfered the files but with incorrect size. Could anybody help me out?

Really appreciate! Urgent.

Alan
----------------------------------------
part of my code looks like:

my $ftp = Net::FTP->new($host, Port=>21, Timeout=>180)
|| die "Could not connect: $host!" unless $ftp;
$ftp->login("anonymous", $email) || die "Login failed";
$ftp->cwd($dir) || die "Directory $dir doesn't exit";

foreach $_ (keys %src)
{
my $file = $src{$_}->{'file'};
$ftp->get($file) || die "can not get $file!";
print "$_: $file is downloaded!\n";

#uncompressing NCBI LocusLink data file
if($file =~ /gz/)
{
my $f = $file;
$f =~ s/.gz//g;
`rm $f`;
`gunzip $file`;
$file =~ s/.gz//g;
`mv $f $root_dir/local_dir`;
print "$_: $file is unzipped!\n";
}
}
$ftp->quit;

Platform: UNIX
Version: Perl 5.6

Reply With Quote
  #2  
Old April 11th, 2003, 04:22 PM
digitsnake's Avatar
digitsnake digitsnake is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Orlando FL
Posts: 130 digitsnake User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via Yahoo to digitsnake
try to make sure you set type to BINARY before do a get()

...

$ftp->binary();

# then do
$ftp->get($file) || die "can not get $file!";
__________________
Help me, help you, help others...

Reply With Quote
  #3  
Old April 11th, 2003, 05:08 PM
alanlh alanlh is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 13 alanlh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Re: Use Net::FTP download file has length error

Thanks much for your kind reply. It works fine now. Another minor question is: I had tried to use `get $file` to download and got a error msg as " not an SCCS file col(1)". I'm just curious about what this means.

Have a nice weekend!

Alan
-----------------------------------------------------
Quote:
Originally posted by alanlh
Hi, guys, my question is:

I used Net::FTP in my script and try to download some zipped files from an ftp website. After downloading I need to unzip them. But the 'gunzip' always complain about those .gz files with "-CRC error" and "-Length error". So I checked the size of downloaded files and found they are several bytes shorter than they are supposed to be. Then I tried to ftp to the site and use 'get' command to download files one by one at the command line. This is successful and the length of files are good and files are unzipped correctly this time. Now I believe this is NOT a gunzip problem but a FTP problem. I don't know why FTP transfered the files but with incorrect size. Could anybody help me out?

Really appreciate! Urgent.

Alan
----------------------------------------
part of my code looks like:

my $ftp = Net::FTP->new($host, Port=>21, Timeout=>180)
|| die "Could not connect: $host!" unless $ftp;
$ftp->login("anonymous", $email) || die "Login failed";
$ftp->cwd($dir) || die "Directory $dir doesn't exit";

foreach $_ (keys %src)
{
my $file = $src{$_}->{'file'};
$ftp->get($file) || die "can not get $file!";
print "$_: $file is downloaded!\n";

#uncompressing NCBI LocusLink data file
if($file =~ /gz/)
{
my $f = $file;
$f =~ s/.gz//g;
`rm $f`;
`gunzip $file`;
$file =~ s/.gz//g;
`mv $f $root_dir/local_dir`;
print "$_: $file is unzipped!\n";
}
}
$ftp->quit;

Platform: UNIX
Version: Perl 5.6

Reply With Quote
  #4  
Old April 14th, 2003, 06:38 AM
digitsnake's Avatar
digitsnake digitsnake is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Orlando FL
Posts: 130 digitsnake User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via Yahoo to digitsnake
humm... I believe SCCS is a source control program. I don't understand why you would get that error message when doing a get command from ftp. Maybe other can help you more.

Reply With Quote
  #5  
Old April 14th, 2003, 10:46 AM
Axweildr's Avatar
Axweildr Axweildr is offline
CPAN medic ...
Click here for more information.
 
Join Date: Mar 2003
Location: Location: Location:
Posts: 11,393 Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)Axweildr User rank is General 27th Grade (Above 100000 Reputation Level)  Folding Points: 123285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 123285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 123285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 123285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 123285 Folding Title: Super Ultimate Folder - Level 1Folding Points: 123285 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Months 2 Days 13 m 42 sec
Reputation Power: 2765
Send a message via Google Talk to Axweildr
Orkut
It could be that the SCCS server is configured to use port 21, and that maybe the FTP service is on another port

Just a guess
Ax

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > Use Net::FTP download file has length error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway