I modified the code like this but the uncompress part seems to give me problem,
Here is the modified code--
#!/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/li
+b C:/Perl/
site/lib .) at ftp1.pl line 3.
BEGIN failed--compilation aborted at ftp1.pl line 3.
Thanks
NT |