Home >Backend Development >Python Tutorial >How to get the results of a long running command in pypsexec?
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)
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!
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
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!