![](/img/trans.png)
[英]How to upload a file starting with Cleanview using net::ftp in perl?
[英]FTP file upload using perl from local system
需求:
我想创建一个脚本,使用perl将文件从本地系统上传到FTP服务器。
样例代码:
use Net::FTP;
$ftp = Net::FTP->new("some.host.name", Debug => 0)
or die "Cannot connect to some.host.name: $@";
$ftp->login("anonymous",'-anonymous@')
or die "Cannot login ", $ftp->message;
$ftp->cwd("/pub")
or die "Cannot change working directory ", $ftp->message;
$ftp->get("that.file")
or die "get failed ", $ftp->message;
$ftp->quit;
PS:Perl中的新手。
您可以尝试此代码,这对我来说很好
use strict;
use warnings;
use Net::FTP;
my ($ftp, $host, $user, $pass, $dir, $fpath);
$host = "";
$user = "";
$pass = "";
$dir = "";
$fpath = "";
$ftp = Net::FTP->new($host, Debug => 0);
$ftp->login($user, $pass) || die $ftp->message;
$ftp->cwd($dir);
$ftp->put($fpath) || die $ftp->message;
$ftp->quit;
print $ftp->message;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.