如何在 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学习者快速成长!