Hi,

I want to write a perl script which will get files from multiple directories
in remote location using FTP. Following is the script that I tried:-

#!/usr/bin/perl
use Net::FTP;
use strict;
for (my $count=0; $count < 2; $count++)
{
print "Please enter the directory name to ftp files: \n" ;
my $dir=<>;
chomp $dir ;
my $ftp = Net::FTP->new("10.48.2.68",Debug => 0) or die "not connected:";
$ftp->login("report",'report') or die "Cant login", $ftp->message;
$ftp->cwd("$dir") or die "Cant change working directory", $ftp->message ;
$ftp->get($_) for grep /\*KO_SPLT\*/, $ftp->ls or die "get failed
",$ftp->message ;
$ftp->quit ;
}

But the get fails. Following message comes:-

rangerfm:/home/ranger/subex_working_area/TEST :>perl ftp1.pl
Please enter the directory name to ftp files:
/backup2/dailyreportbackup/20090402
get failed Opening ASCII mode data connection for file list.
Transfer complete.

There is a file in the above mentioned directory which is
"07_KOL_KO_SPLT_20090402.txt.gz".
I want to ftp this file.

Can you please help on why "get" is failing in this case. Since mget doesnt
work with Net::FTP, I found an alternative way on net which I tried using.

Thanks,
Mihir

Reply via email to