Fellow monks..
I'm using a script to look for a file and then send it to a vendor FTP site. The script "appears" to work. However, when I check the ftp directory, the file isn't there. If I perform the FTP manually, the file is present. I've turned debug on within Net::FTP and it looks like it is transferring but as I said, it never does. Any thoughts or advice would be appreciated.
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;
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.