How to get the results of a long running command in pypsexec?

WBOY
Release: 2024-02-12 11:30:05
forward
1236 people have browsed it

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

Question content

I am using pypsexec to connect to a remote windows computer. I have to find a list of files with a specific extension. That's what I'm doing now.

command = "dir /b/s *.py"
client.run_executable("cmd.exe", arguments=f"/c {command}", asynchronous=True)
Copy after login

When I don't use async parameters, I don't receive any response at first. After reading the documentation, I can see that long running tasks (such as mine) should use this parameter. However, it does not provide clear instructions on how to get the output after the job completes.

Thanks in advance!


Correct answer


This is because you can't get the output. See 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
Copy after login

As you can see, when using asynchronous=true, stdout and stderr will always be none

The above is the detailed content of How to get the results of a long running command in pypsexec?. For more information, please follow other related articles on the PHP Chinese website!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!