Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NET::FTP 1

Status
Not open for further replies.

fmuquartet

Programmer
Joined
Sep 21, 2006
Messages
60
Location
US
I am wanting to retrieve a remote file and store it locally using NET::FTP, but I am getting the error "Cannot open Local file /tmp/file.zip: No such file or directory."

Have I missed something?

Script:

my $ftp_server = 'somehost.com';
my $ftp_userid = 'user';
my $ftp_passwd = 'pass';
my $ftp_from_dir = '/zip';
my $ftp_to_dir = ' /tmp';
my $file = '';
my $ftpConnection = Net::FTP->new($ftp_server, Debug => 1);

if (!$ftpConnection->login($ftp_userid,$ftp_passwd)) {
$logger->error("FTP failed: Could not login\n");
$ftpConnection->quit;
}

$logger->debug("FTP: Logged in to $ftp_server as $ftp_userid\n");
$ftpConnection->binary;

$file="ga01.zip";
getfile($file);
$file="ga01a.zip";
getfile($file);

$ftpConnection->quit;
$logger->info("FTP: Logged out\n");

exit;


sub getfile {
my $file = shift @_;
if ($ftpConnection->get("$ftp_from_dir/$file","$ftp_to_dir/$file")) {
$logger->info("Downloading $file Successful\n");
} else {
$logger->error("Downloading $file Failed\n");
$ftpConnection->quit;
return 2;
}
}
 
MillerH, It appears that I am now getting CRC errors with the script, I need a way of checking if a file exist (dest. dir) and if so remove it before copying file out to destination directory.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top