mbeason has asked for the wisdom of the Perl Monks concerning the following question:
use Net::FTP; my $local_dir = "/home/best1"; my $remote_dir = "/incoming"; my $ftp_site = "ftp.bmc.com"; my $mail_text = "nonew_mail.file"; my $caseid = ""; my $tarbundle = ""; # Find all the caseid tar bundles opendir(HOMEDIR, "$local_dir"); foreach my $file (readdir HOMEDIR) { next if($file eq ".") or ($file eq ".."); if($file =~ /case\d+\.tar\.gz/) { $tarbundle = $file; if($tarbundle =~ /(\d+)/) { $caseid = $1; &ftp; unlink("$local_dir/$tarbundle"); } } } # subroutine for FTP processing sub ftp { $ftp = Net::FTP->new("$ftp_site", Debug => 1) or die "Cannot connect t +o $ftp_site: $@"; $ftp->login("anonymous",'-anonymous@') or die "Cannot login ", $ftp->m +essage; $ftp->cwd("$remote_dir") or die "Cannot change working directory ", $f +tp->message; $ftp->mkdir("$caseid") or die "Cannot create directory ", $ftp->messag +e; $ftp->binary; $ftp->put("$local_dir/$tarbundle") or die "get failed ", $ftp->message +; $ftp->quit; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::FTP Issues
by BrowserUk (Patriarch) on May 31, 2006 at 17:22 UTC | |
by mbeason (Novice) on May 31, 2006 at 17:34 UTC |