3 # simpleftp - Rudimentary FTP client.
5 # Author: David Lawrence <tale@isc.org>.
6 # Rewritten by Julien Elie <julien@trigofacile.com> to use Net::FTP.
8 # Fetch files to the local machine based on URLs on the command line.
9 # INN's configure searches for ncftp, wget, linx, et caetera,
10 # but they're all system add-ons, so this is provided.
12 # Perl 5 is already required by other parts of INN; it only took a half hour
13 # to write this, so this was the easiest way to go for a backup plan.
15 # This script is nowhere near as flexible as libwww. If you really need
16 # that kind of power, get libwww and use it. This is just sufficient for what
25 my $usage = "Usage: $0 ftp-URL ...\n";
37 # This will keep track of how many _failed_.
41 my ($host, $path) = m%^ftp://([^/]+)(/.+)%;
42 my $user = 'anonymous';
43 my $pass = (getpwuid($<))[0] . '@' . hostname;
46 unless (defined $host && defined $path) {
47 warn "$0: bad URL: $_\n";
51 if ($host =~ /(.*):(.*)\@(.*)/) {
57 if ($host =~ /(.*):(.*)/) {
62 if (defined $lasthost && $host ne $lasthost) {
67 unless (defined $lasthost) {
68 $ftp = Net::FTP->new($host, Port => $port)
70 $ftp->login($user, $pass)
74 my $localfile = $path;
76 $localfile =~ s(.*/)();