This shows you the differences between two versions of the page.
ftp_file_fetch_using_perl [2009/08/09 02:15] k2patel |
ftp_file_fetch_using_perl [2020/08/10 02:35] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== FTP file fetch using perl ====== | ||
- | |||
- | <code 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 "/srv/www/htdocs/passwd"; | ||
- | |||
- | $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"; | ||
- | </code> |