mbeason has asked for the wisdom of the Perl Monks concerning the following question:

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; }

Replies are listed 'Best First'.
Re: Net::FTP Issues
by BrowserUk (Patriarch) on May 31, 2006 at 17:22 UTC

    You appear to be making a directory on the remote system, but you never cwd into it. Try looking one level up for the files.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Thanks Browser! Sometimes, all it takes is another set of eyes! It works great now!