I need some help trying to download files from an FTP site based on their timestamp or date format(MMDDYYYY), then send an email if the download was successful or not.
So far I setup Net::FTP to successfully download the file if I specify the exact filename. I have not been able to successfully setup $ftp->_MDTM($file) to download any files that have a timestamp with today's date. I would also like to setup Net::SMTP to send an email stating if the file transfer was successful or not.
Any help or information would help. The following is my current script(not complete by any means).
#!/usr/bin/perl # pegasus_ftp_transfer use Net::FTP; use Time::Format qw(%time %strftime %manip); $ctime="$time{'hh:mm'}"; $cdate=$time{mmddyy}; $file_month=$time{'mmddyy'}; $filename= "property_odd04012004.gz"; $ftp_log="pegasus_ftp_transfer.log"; $down_dir = "c:"; $ftp = Net::FTP->new("host", Debug => 0) or die "Cannot connect to some.host.name: $@"; $ftp->login("user","pass") or die "Cannot login ", $ftp->message; $ftp->ascii; $ftp->cwd("/pegasus") or die "Cannot change working directory ", $ftp->message; $ftp->mdtm ($filename) or die "get failed ", $ftp->message; $ftp->quit; 'mv $filename > $down_dir';
Edit by castaway, added code tags
In reply to FTP pattern matching and email notify by brianlois
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |