#!/usr/bin/perl use strict; use warnings; use Net::FTP; use Net::Netrc; my $server = "X.X.X.X"; my $user = "user"; my $password = "password"; my $destination = "/www/ftp"; my $file = "/home/files/testfile.txt"; my $ftp = Net::FTP->new ($server, Timeout => 9000, Debug => 3); $ftp or die "$server: cannot connect: $@"; $ftp->login ($user,$password) or die "$_: Could not login: " . $ftp->message; $ftp->cwd($destination); if (-f "$file") { $ftp->ascii; my $remote_name = $ftp->put($file); $remote_name or die "$server: cannot put $file: " . $ftp->message; } $ftp->quit;