0

我正在尝试上传以 Cleanview 开头的文件,完整的文件名将在中间包含随机字符,如“Cleanview.45673.log”。我需要找到文件名以 Cleanview 开头的文件并上传。我尝试了如下代码,但它不起作用。该文件是在服务器上创建的,但大小为零字节。请帮忙。

$login = 'abc';
$pass = 'xyz';
$dir = '/projects/ban/android/BX';
$ftp = Net::FTP->new('10.xxx.xx.xxx' ,Debug => 1) or die "Cannot connect";
print("FTP session opened for logs\n");
$ftp->login($login, $pass) or die "Can't log $login in\n";
$ftp->pasv();
$ftp->cwd($dir);
my @cleanviewlog = glob "CleanView*.log";
$ftp->pasv;
for(@cleanviewlog)
{
 print "Transferring CleanView log $_\n";
 $ftp->put("$_") or die $ftp->message;
 sleep(5);
}

这是显示的调试消息:

Transferring CleanView log CleanView.66411936.log
Net::FTP=GLOB(0x202697f0)>>> ALLO 1958
Net::FTP=GLOB(0x202697f0)<<< 227 Entering Passive Mode (10,131,32,173,161,61)
Net::FTP=GLOB(0x202697f0)>>> PORT 10,32,128,60,230,164
Net::FTP=GLOB(0x202697f0)<<< 202 ALLO command ignored.
Net::FTP=GLOB(0x202697f0)>>> STOR CleanView.66411936.log
Net::FTP=GLOB(0x202697f0)<<< 200 PORT command successful. Consider using PASV. PORT command successful. Consider using PASV.
4

1 回答 1

0

If the file is being transferred, but has zero size, then probably IO is buffered and you are transferring the file after it is created but before the contents of the buffer is flushed. Maybe you need to close the filehandle that creates the file? Or flush the buffer that is writing to the file? There's not enough information in your question to tell for sure exactly what the solution is.

于 2013-08-14T19:00:54.957 回答