Hi All,
I have a Perl code which performs ftp-ing of files.
However, it seems like the variable $date_today is not passed on to this statement grep { /^ME.*JMR.*$date_today.*sorts$/ } and i can't ftp the files that i wanted.
Can any expert help me to debug this ?
Is there any thing wrong with my date syntax $date_today = `date '+%y%m%d'`; ?
#!/usr/local/bin/perl
use Net::FTP;
$TEMP = "$script_dir/TEMP";
date_format ();
foreach $t ( 10.12.80.19 ) {
chdir "$TEMP";
print "Now Processing $t ...\n";
$ftp = Net::FTP->new("$t", Timeout=>240, Debug => 0)
or die "Cannot connect to some.host.name: $@";
$ftp->login("login",'password')
or die "Cannot login ", $ftp->message;
$ftp->cwd("/mydirectory")
or die "Cannot change working directory ", $ftp->message;
my @lines = grep { /^ME.*KMR.*($date_today|$date_yest).*sorts$/ } $ftp->ls();
foreach my $filename (@lines) {
$ftp->get($filename);
};
$ftp->quit;
};
sub date_format {
$date_today = `date '+%y%m%d'`;
$date_yest = $date_today - 1;
return ($date_today, $date_yest);
}