我想在 Perl 脚本中使用 Windows 内置 FTP 工具来测量链接的吞吐量。因此,该脚本会创建以下命令脚本:
open <ip>
<username>
<password>
hash
get 500k.txt
quit
之后,我使用以下 Perl 代码运行命令脚本:
system(@args);
@args = ("ftp", "-s:c:\\ftp_dl.txt");
system(@args);
如果我在 DOS 框中运行命令,则输出如下所示:
ftp> open <ip>
Connected to <ip>
220 "Welcome to the fast and fabulous DUFTP005 ftp-server :-) "
User (<ip>:(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 不是很熟悉。有人知道如何获得那条线吗?