haps has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl my $host = 'ftp.iinet.net.au'; my $arch = 'i386'; my $ver = '4.3'; use Net::FTP; my $package = shift; my $ftp = Net::FTP->new($host, debug => 0) or die "Cant connect: $@"; $ftp->binary(); $ftp->login("anonymous", "-anonymous@") or die "Cant login: ", $ftp->m +essage; $ftp->cwd("pub/OpenBSD/$ver/packages/$arch") or die "Cant change dir: +", $ftp->message; my @pkglist = $ftp->ls or die "Cant get dir listing: ", $ftp->message; for( @pkglist ) { my $pkg = $_; unless( $pkg =~ $package ) { next; } $pkg =~ s/\S\s{7}?//; my $test = promptUser( "Download package?", "y" ); if( $test eq "y" ) { $ftp->get( $pkg ) or die "Cannot retrieve matching package: ", + $ftp->message; } } sub promptUser { local( $promptString, $defaultValue ) = @_; if ( $defaultValue ) { print $promptString, "[", $defaultValue, "]: "; } else { print $promptString, ": "; } $| = 1; $_ = <STDIN>; chomp; if ("$defaultValue") { return $_ ? $_ : $defaultValue; } else { return $_; } } exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problems with Net::FTP
by zentara (Cardinal) on Jan 05, 2009 at 16:14 UTC | |
by haps (Novice) on Jan 05, 2009 at 16:26 UTC | |
|
Re: Problems with Net::FTP
by eye (Chaplain) on Jan 06, 2009 at 07:18 UTC | |
by haps (Novice) on Jan 07, 2009 at 00:49 UTC |