我无法使用Net :: Ftp获取文件大小。我收到的错误是“file1.csv:没有这样的文件或目录。”我确定文件存在。 $ftp->supported('size')
返回true。使用完整路径('/otherdir/file1.csv')会导致相同的错误。在我使用的目录中没有子目录&所有文件的大小都大于0。我究竟做错了什么?我已将代码剥离到以下代码片段 -为什么我无法使用Net:FTP获取文件大小?
#! /usr/bin/perl
use strict;
use warnings;
use Net::FTP;
my $ftp = Net::FTP->new("host", Debug =>0) or die "couldnt connect: [email protected]";
$ftp->login("username","password") or die "couldnt login: ", $ftp->message;
$ftp->binary;
$ftp->cwd("otherdir") or die "couldn't cwd ", $ftp->message;
my @ftp_files = $ftp->ls();
print scalar(@ftp_files);
foreach (@ftp_files){
print $_,"\n";
my $size= $ftp->size($_) or die $ftp->message;
print $size,"\n";
}
只是一个侧面说明,它也将死亡时,文件大小为零 –
@mpapec谢谢你。有大约20个文件在服务器上&我肯定都有一个大小> 0。 – Janelle
您可以在大小(第一个循环线)之前打印文件名吗? Thx – DVK