gpt4 book ai didi

perl - 为什么这个使用 tcpreplay 的脚本不等待用户输入?

转载 作者:行者123 更新时间:2023-12-01 05:14:16 30 4
gpt4 key购买 nike

以下代码段只会等待用户第一次点击 Enter;之后,它会循环遍历所有剩余的 .pcap 文件,而无需等待用户输入。

$| = 1;

while (<*.pcap>) {
print "$_";
<STDIN>;

system("tcpreplay -i eth0 -M 20 $_");
}

为什么这不在每次循环迭代时都等待用户输入?

最佳答案

你关心tcpreplay输出吗?重定向 stdout 和 stderr 似乎可以解决这个问题:

system("tcpreplay -i eth0 -M 20 $_ >/dev/null 2>&1");

或者,您可以使用它来捕获 tcpreplay 输出:

my $tcpreplay_output = `tcpreplay -i eth0 -M 20 $_ 2>&1`;

关于perl - 为什么这个使用 tcpreplay 的脚本不等待用户输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36386192/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com