[英]How to read output from an application using python
當前正在嘗試記錄傳出 TCP 連接列表,然后將當前列表與前一個列表進行比較,以查看已建立的連接。 但是,TCPView.exe 似乎不走運。 我可以用這個運行應用程序:
def get_tcp_conns():
process = Popen([r"C:\Users\PC\Downloads\TCPView\Tcpview.exe"], stdout=PIPE, shell=True)
for line in io.TextIOWrapper(proc.stdout, encoding="utf-8"):
print(line) # Do whatever here
但是,這不會返回任何文本。 不確定該去哪里,因為我不知道如何在 python 中讀取 TCP 信息
應該是這樣的
import subprocess
def get_tcp_conns():
process = subprocess.run("C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe './C:Users/PC/Downloads/TCPView/Tcpview.exe' ", shell=True, capture_output=True)
print(process.stdout)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.