I 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.
Start Free Trial