linebacker has asked for the wisdom of the Perl Monks concerning the following question:
#!/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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::FTP Server does not support cwd...alternatives?
by kvale (Monsignor) on Jun 14, 2002 at 17:34 UTC | |
by linebacker (Scribe) on Jun 14, 2002 at 17:57 UTC | |
|
Re: Net::FTP Server does not support cwd...alternatives?
by atopolc (Pilgrim) on Jun 14, 2002 at 17:26 UTC |