#!/usr/bin/perl
#ok, let's begin.
use Net::FTP;
#set some variables
$host = "10.20.30.40";
$user = "username";
$pass = "password";
$path = "/home/mengge/testpath";
#login to host && change cwd
my $ftp = new Net::FTP($host);
$ftp->login($user,$pass) || die "Error on logging in : $!";
$ftp->cwd($path) || die "Error on changing directory : $!";
#list files in the cwd
my @AllFiles = $ftp->ls();
foreach my $file (@AllFiles)
{
print "$file/n";
}
#after list, quit
$ftp->quit();
#end of this script.
用Perl写的FTP客户端程序
最新推荐文章于 2022-03-03 12:43:51 发布