我無法使用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