0

我正在尝试使用 python 从 tcpdump 输出中读取。我正在使用子进程从 Fedora、redhat、SUSE 上的 tcpdump stdout 读取,但实际上我的脚本在 Ubuntu 上不起作用。我的问题听起来像这个问题http://stackoverflow.com/questions/7163877/getting-stdout-from-a-tcpdump-subprocess-after-terminating-it,但实际上,我没有找到合适的解决方案。这是我的python代码:

tcp_cmd = "tcpdump -i eth2 dst 224.1.1.1"

tcp_handle = Popen(tcp_cmd,shell=True,stdout=PIPE, stderr=PIPE)

tcp_handle.terminate()

result = tcp_handle.stdout.read()`enter code here`

print result
4

0 回答 0