我有一个具有以下凭据的安全ftp:
host: x.x.x.x
username: username1
password: password1
此后,我在ftp中创建了一个目录,并使用其他凭据对其进行了保护:
path: x.x.x.x/newDirectory/
username: username2
password: password2
我一直在尝试使用下面的Perl代码提供的凭据访问我的newDirectory文件夹:
use Net::FTP;
my $host="x.x.x.x/newDirectory/";
$ftp = Net::FTP->new->($host,Debug => 0) or die;
$ftp->login("username2",'password2') or die;
系统提示我错误“主机名错误”。
new ([ HOST ] [, OPTIONS ])
This is the constructor for a new Net::FTP object. "HOST" is the
name of the remote host to which an FTP connection is required.
字符串"x.x.x.x/newDirectory/
“不是有效的主机名。您需要登录FTP服务器,然后将目录更改为
newDirectory
。您需要这样的东西(未经测试的)
use Net::FTP; my $host="x.x.x.x"; $ftp = Net::FTP->new->($host,Debug => 0) or die; $ftp->login("username2",'password2') or die; $ftp->cwd("newDirectory");