Perl FTP Script

Perl FTP Script

perl 

 

 

This nice little Perl script that I wrote that will take a set of files from a folder and FTP them to a specified host.

It is pretty simple. There are tons of scripts out there that will the same. I hope you find it useful. 

 Enjoy!

 

<code>

#!/usr/local/bin/perl
###FTP PROCESS##
#Variables
########################################
   
###Username
$USERNAME = “”;
###Host name or address
$HOST = “”;
###Password 
$PASSWORD = “”;
#Directory where the files you want to move reside
$LOCALDIR = “”;
#####Extension of the files you want to move – You can use wild characters.
$ext =”";
#######Do not edit below this line ###########################
 
 my $dir = “$LOCALDIR”;
 my @files = <$dir/$ext>;
 foreach my $transferfiles (@files)
 
 {
 ####print “files to be transfered \n”; For testing purposes only
 ####print “$transferfiles \n”; For testing purposes only
 use Net::FTP;
 $ftp = Net::FTP->new(“$HOST”, Debug=>0);
 die “Cannot Connect to $HOST  $!” unless $ftp;
 $ftp->login(“$USERNAME”,”$PASSWORD”, Debug=>0);
 $ftp->cwd(“$LOCALDIR”);
 $ftp->put(“$transferfiles”);
 $ftp->quit;
 }

<code>

About the Author