Thank you for your comment the script was timing out so I increased the timeout time and that solved the problem
Main Topics
Browse All TopicsI have created a script to download several zip files over 50 files. There are two problems that I am running into, first there are two folders in the directory were the files are. The folders do not need to be downloaded, and the second is that the script does not download all the files it usually downloads something like 50 - 52 files I need it to download all files but not the folders here is a copy of my script please help me figuer out what I am doing wrong.
[start code]
#!/usr/bin/perl
use Net::FTP;
use Archive::Extract;
use File::Listing qw(parse_dir);
$host = 'myhost.com';
$path = '/mydir/data/';
$ftp = Net::FTP->new($host, Timeout => 1800) or die "Cannot contact $host: $!";
$ftp->login('username', 'password') or die "Cannot login ($host):" . $ftp->message;
$ftp->cwd($path) or die "Cannot change directory ($host):" . $ftp->message;
@Files = $ftp->ls('-lR');
$ftp->binary();
foreach $file (parse_dir(\@Files))
{
my($name, $type, $size, $mtime, $mode) = @$file;
print "Retrieving $name \n";
print "File type $type \n";
if ($type != 'f')
{
print "File name: $name";
print "File type: $type";
}
if ($type eq 'f')
{
$ftp->hash($name,102400);
$ftp->get($name, "C:/Temp/$name") or warn "Could not get $_, skipped: $!";
EXTRACT("C:/temp/$name");
}
}
$ftp->quit or die "Could not close the connection cleanly: $!";
sub EXTRACT
{
my $ae = Archive::Extract->new( archive => @_ );
my $ok = $ae->extract( to => 'C:/temp/central/dnld' );
}
exit;
[code end]
one last thing I have also include a step to unzip all the files as it finishes the download. What is wrong with this thing.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: jmcgPosted on 2007-04-09 at 19:58:30ID: 18880110
The fact that your script successfully downloads some files means that it is substantially correct and leads me to suspect that there is some data dependency that is causing your script to fail: running into a transfer problem from the FTP server, running out of disk space, etc.
The first thing to check is the content of @Files to be sure that it contains everything you expect it to contain. Then, if the "foreach $file" loop exits early, before all the files are transferred, I'd look at whether there's an uncaught error occurring in the 'extract' method.
For perfectionism, check whether the call to the 'hash' method is working the way you want. As I read it, you should only need to call it once per ftp session, not for every file. The $file parameter you're passing is evaluated as to true or false, but otherwise ignored.