#!/usr/bin/perl
use Net::FTP::Recursive;
use FileHandle;
####################################################################
# will assume just a few args, as well as validity.
####################################################################
usage() unless @ARGV == 5;
$host = shift;
$username = shift;
$passwd = shift;
$remote_path = shift; #where to grab from
$filename = shift;
$fh = new FileHandle;
$fh->open(">$filename");
select $fh;
$| = 1;
select STDOUT;
$ftp = Net::FTP::Recursive->new($host, ); #Debug => 1);
$ftp->login($username, $passwd) or die "Could not log in!";
$ftp->binary();
$ftp->cwd($remote_path);
$ftp->rdir( FilenameOnly => 1, Filehandle => $fh, PrintType => 1 );
$fh->close;
$ftp->quit;
sub usage {
my($name) = $0;
$name =~ s/.*\///;
print STDERR "Usage: $name <host> <username> <passwd> <remote_path> <output_file>\n";
exit;
}
syntax highlighted by Code2HTML, v. 0.9.1