#!/usr/bin/perl -w # ----------------------------------------------------------- # FTP script # ----------------------------------------------------------- use Net::FTP; $host = 'ftp.ftpserver.com'; $user = 'anonymous'; $pass = 'someone@somewhere.com'; $remote_dir = '/pub/path/to/files'; $download_filter = "*.myfile.exe"; $destination_dir = "./"; print "Opening FTP connection to $host\n"; my $ftpBox = Net::FTP->new($host) || die "failed to connect to $host $!"; $ftpBox->login($user, $pass) || die "failed to log onto $host $!"; $ftpBox->pasv(); if($remote_dir !~ /^ *$/) { print "Changing remote directory to $remote_dir\n"; $ftpBox->cd($remote_dir) || die "failed to cwd to $remote_dir on $host ftp $!"; } @file_list = $ftpBox->ls($download_filter); foreach $filename (@file_list) { print "getting $filename\n"; $ftpBox->get($filename, $destination_dir . $filename) || die "failed to get $filename to $destination_file"; } print "Closing FTP download connection...\n"; $ftpBox->quit;