Perl对FTP的上传和下载

下面是 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值