我想在Perl脚本中使用Windows内置FTP工具来确保链接的吞吐量.因此,该脚本将创建以下命令脚本:
openhash get 500k.txt quit
然后我使用以下Perl代码运行命令脚本:
system(@args); @args = ("ftp", "-s:c:\\ftp_dl.txt"); system(@args);
如果我在DOS框中运行命令,输出如下所示:
ftp> openConnected to 220 "Welcome to the fast and fabulous DUFTP005 ftp-server :-) " User ( :(none)): 331 Please specify the password. 230 Login successful. ftp> hash Hash mark printing On ftp: (2048 bytes/hash mark) . ftp> get 500k.txt 200 PORT command successful. Consider using PASV. 150 Opening BINARY mode data connection for 500k.txt (14336 bytes). ####### 226 File send OK. ftp: 14336 bytes received in 0.00Seconds 14336000.00Kbytes/sec. ftp> quit 221 Goodbye.
为了能够获得吞吐量,我需要提取该行:
ftp: 14336 bytes received in 0.00Seconds 14336000.00Kbytes/sec.
我对Perl不太熟悉.有人知道如何获得这条线吗?
使用管道模式打开:
open($filehandle, "$command|") or die "did not work: $! $?"; while(<$filehandle>) { #do something with $_ }
或使用反引号:
my @programoutput=`$command`