如何在 pypsexec 中取得長時間運行命令的結果?

WBOY
發布: 2024-02-12 11:30:05
轉載
1236 人瀏覽過

如何在 pypsexec 中获取长时间运行命令的结果?

問題內容

我正在使用 pypsexec 連接到遠端 windows 電腦。我必須找到具有特定擴展名的文件列表。這就是我現在正在做的事情。

command = "dir /b/s *.py"
client.run_executable("cmd.exe", arguments=f"/c {command}", asynchronous=True)
登入後複製

當我沒有使用非同步參數時,一開始我沒有收到任何回應。閱讀文件後,我可以看到長時間運行的任務(例如我的任務)應該使用此參數。但是,它沒有提供有關如何在作業完成後取得輸出的明確說明。

提前致謝!


正確答案


這是因為你無法得到輸出。請參閱 https://github.com/jborean93/pypsexec /blob/master/pypsexec/client.py#l436-l466

if not interactive and not asynchronous:
    [...] # Here is where stdout and stderr is set
else:
    stdout_out = None
    stderr_bytes = None

[...] # Here is some code that doesn't change stdout_out or stderr_bytes

return stdout_out, stderr_bytes, return_code
登入後複製

如您所見,使用 asynchronous=true 時,stdout 和 stderr 將始終為 none

以上是如何在 pypsexec 中取得長時間運行命令的結果?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

來源:stackoverflow.com
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!