#!/usr/bin/perl
use Net::FTP;
#use IO::Uncompress::Unzip qw(unzip $UnzipError) ;
use IO::File ;
print "Retrieving file from abc.com...\n";
$loginip='123.456.0.23';
$loginid='nt1234';
$loginpaswd='defgsljf';
($sec,$min,$hour,$mday,$mon,$year)=(localtime(time))[0,1,2,3,4,5];
$time_stamp= "_" . (1900+$year) . "_" . ($mon+1) . "_" . ($mday) . "_" . $hour . "_" . $min . "_". $sec;
printf "time stamp = $time_stamp\n";
unless(-d "temp")
{
mkdir("temp");
}
if( -d "temp")
{
chdir("temp");
}
$ftp = Net::FTP->new(($loginip), Debug => 0)
or die "Cannot connect to abc.com: $@ \n";
$ftp->login($loginid,$loginpaswd)
or die "Cannot login ", $ftp->message;
$source_dir="/abc/nali05/";
$ftp->cwd($source_dir)
or die "Cannot change working directory ", $ftp->message;
$ftp->binary || die "Unable to set mode to binary. ", $ftp->message;
@list=$ftp->ls();
printf "list = \n";
print @list;
foreach $file (@list)
{
#unzip "$file" => "$source_dir"' or die "unzip failed: $UnzipError\n";
#if($file =~ m/namish*/i)
#{
$ftp->get($file) or die "get failed ", $ftp->message;
#rename($file,"${file}_${time_stamp}");
$ftp->delete ($file) or die "rm -rf failed ", $ftp->message;
#}
}
$ftp->quit;
When i use my code without uncompress part it works fine. But i want to uncompress it first and choose files and ftp only those files.
When i run the script i get this error--
C:\Perl Script>perl ftp1.pl
Can't locate IO/Uncompress/Unzip.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/
site/lib .) at ftp1.pl line 3.
BEGIN failed--compilation aborted at ftp1.pl line 3.
I searched for the uncompress aprt and tried that but that seem to be working. Kindly give some suggestions as how to get rid of this....
You're trying to use unzip without the module being installed, hence the error message. If you're using ActiveState's Perl, IO::Uncompress::Unzip should be available through PPM
It looks like you're trying to uncompress the Zip on the remote server, but FTP doesn't support this. You'll have to download the file.
Thanks for the suggestions. But i could not understand this line
You're trying to use unzip without the module being installed, hence the error message. If you're using ActiveState's Perl, IO::Uncompress::Unzip should be available through PPM
How i can use this to get rid of the problem or if i do not want to install anything then what i can use to get it working.
The later one i will modify.
I can see in my perl modules that these files are there, but still when i ran the script i got these erros--
Can't locate auto/Compress/Raw/Zlib/autosplit.ix in @INC (@INC contains: C:/Perl
/lib C:/Perl/site/lib .) at C:/Perl/lib/AutoLoader.pm line 160.
at C:/Perl/lib/Compress/Raw/Zlib.pm line 6
Can't locate loadable object for module Compress::Raw::Zlib in @INC (@INC contai
ns: C:/Perl/lib C:/Perl/site/lib .) at C:/Perl/lib/IO/Uncompress/RawInflate.pm l
ine 8
Compilation failed in require at C:/Perl/lib/IO/Uncompress/RawInflate.pm line 8.
BEGIN failed--compilation aborted at C:/Perl/lib/IO/Uncompress/RawInflate.pm lin
e 8.
Compilation failed in require at C:/Perl/lib/IO/Uncompress/Unzip.pm line 11.
BEGIN failed--compilation aborted at C:/Perl/lib/IO/Uncompress/Unzip.pm line 11.
Compilation failed in require at ftp1.pl line 3.
BEGIN failed--compilation aborted at ftp1.pl line 3.
i have the required files in perl/lib i cross checked but still the error persistes. I want to get rid of these errors.
Thanks
NT
---------- Post updated at 10:51 AM ---------- Previous update was at 10:23 AM ----------
Hi,
I want to clear what exactly i am doing here..
I wrote the above perl script to get the files in a specifed directory called temp. The files which i get all are zipped ones. I want to unzip all the files and choose some which of my interest and delete rest of the files. I achieved the first part but i am struglling for the second.
The files which i am getting after ftp are like this--
Bumping up posts isn't allowed. Also, this isn't a paid-for support forum with guaranteed response times, so you can't expect people to respond ASAP.
From what I'm seeing above, you're missing the Perl module Compress::Raw::Zlib. The trace is: IO::Uncompress::Unzip requires IO::Uncompress::RawInflate requires Compress::Raw::Zlib. Install that module properly and everything should be fine.