sub query_ftp()
{
use Net::FTP;
my $ftp_host = q/ftp_host/;
my $username = q/username/;
my $password = q/password/;
my $ftp = Net::FTP->new($ftp_host, Debug => 0)
or die "Cannot connect to $ftp_host: $@";
$ftp->login($username, $password)
or die "Cannot login ", $ftp->message;
my $dir = q{A/B/C};
$ftp->cwd($dir) or die "Cannot cwd to $dir\n";
my @ls = $ftp->ls();
my $ts;
foreach my $ls_detail ($ftp->ls('-lR')) {
$ts = substr($ls_detail, 46, 12) if ($ls_detail =~ /$ls[-1]/);
}
printf "%20s%30s\n", $ls[-1], $ts;
$ftp->cwd() or die "Cannot cwd to root\n";
}
2012年8月10日 星期五
[Perl] Query FTP by Net::FTP
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言