User Tools

Site Tools


ftp_file_fetch_using_perl

This is an old revision of the document!


FTP file fetch using perl

| fetch.pl
#!/usr/bin/perl                                      
# this script is written by ketan patel
 
use Net::FTP;
 
$file = "name of file";
 
@paths = ('comma_separated path file');
 
$remotehost = "<remote_hostname>";
$user = "<ftp_username>";
$pass = "<ftp_password>";
 
chdir "/www/virtual/hugh797/passync";
 
$k2=1;
print "Connecting...\n";
$ftp = Net::FTP->new("$remotehost", Debug => 0) or
      die "cannot connect:";
 
print "Logging in...\n";
$ftp->login("$user","$pass")
      or die "cannot login: ",$ftp->message;
 
print "Beginning Transfer...\n";
 
foreach $paths (@paths)
{
 print "$paths/$file..\n";
 $ftp -> cwd($paths);
 print "xfering $file..\n";
 $ftp->get($file,"$file$k2");
 $ftp->message;
 $k2++;
}
 
print "Done.\n";
ftp_file_fetch_using_perl.1241248232.txt.gz · Last modified: 2020/08/10 02:30 (external edit)