我使用Net::FTP将文件传输到大型机,并测试失败条件。
我的代码基本上如下所示:
my $ftp = Net::FTP->new ("mainframe.com", Timeout => 20);
if (! $ftp) {
logMessage ("Could not connect to host: $!");
return;
}
if (! $ftp->login ("paxdiablo", "demigodemporeroftheuniverse")) {
logMessage ("Could not log in to host: $!");
$ftp->quit ();
return;
}
if (! $ftp->put ("myfile.txt", "'CANT.WRITE.TO.THIS'")) {
logMessage ("Could not put file: $!");
$ftp->quit ();
return;
}我知道我无法创建数据集CANT.WRITE.TO.THIS,因为我没有所需的权限,但是,当我尝试时,我看到的唯一消息是:
Could not put file:在$!中没有任何迹象表明问题是什么。我在多科里查过,上面写的是:
put ( LOCAL_FILE [, REMOTE_FILE ] )Put a file on the remote server. LOCAL_FILE may be a name or a filehandle. If LOCAL_FILE is a filehandle then REMOTE_FILE must be specified. If REMOTE_FILE is not specified then the file will be stored in the current directory with the same leafname as LOCAL_FILE.Returns REMOTE_FILE or the generated remote filename if REMOTE_FILE is not given.
我在那里也找不到关于检索特定错误的任何信息(比如$ftp->getLastError()或类似的东西)。
如何向用户说明传输失败的原因?
在早期的迭代中,我求助于放置文件,然后再次获取文件,并在本地检查内容。我真的不想再把这种乱七八糟的代码强加给人们了。
发布于 2012-01-27 06:01:35
来自Net::FTP
$ftp = Net::FTP->new("some.host.name",Debug => 0)或死版“无法连接到some.host.name:$@”
注$@.
$ftp->cwd("/pub")或死“不能更改工作目录",$ftp->消息;
注$ftp->message
https://stackoverflow.com/questions/9029398
复制相似问题