下面是 FTP上传和下载的pl代码,上传下载用get/put来获取。
use net::ftp;
my $username = "liuweichuanusrname";
my $password = "liuweichuanpassword";
my $remotefile = "test.txt";
my $localfile = "a.txt";
my $remotefilename = "111";
my $filename = "C:/Users/liuweic/Documents/FFOutput/Animals United 动物总动员 00_54_00-00_55_11.avi";
$ftp = Net::FTP->new("16.173.246.xx",Timeout => 30) or die "Can't connect: $@\n";
$ftp->login($username, $password) or die "Could not log in.\n";
$ftp->cwd('/var');
print "I'm in the directory ", $ftp->pwd( ), "\n";
@lines = $ftp->ls("/UXMON") or die "Can't get a list of files in /pub/gnat/perl: $!";
print @lines;
$ftp->get($remotefile, $localfile) or die "Can't fetch $remotefile : $!\n";
$ftp->put($filename, $remotefilename) or die "Couldn't put $filename\n";
$ftp->quit( ) or warn "Couldn't quit. Oh well.\n";
print "\nquit";
注意,转载请注明出处和作者,作者:NO. Liu