我想直接在Python
中运行以下命令:
dumpcap -q -f http -i eth0 -w - | tshark -l -n -T json -r - | my_app.py
我想通过使用subprocess
和asyncio
来运行它,让它在async
中运行
因此,首先我想运行:
dumpcap -q -f http -i eth0 -w -
此命令的输出应通过管道传输到下一个命令,该命令应/可能不同步运行:
tshark -l -n -T json -r -
这个输出应该通过管道传输到我可以使用的流中
有没有一个简单的解决方案
除了@user4815162342的答案之外,请注意,您只需将完整的shell命令传递给create_subprocess_shell,并使用管道与子流程的两端进行通信:
例如:
子流程文档中的example也应适用于异步IO子流程。例如(未经测试):
相关问题 更多 >
编程相关推荐