I tried using subprocess.run
as described in this answer, but it doesn't return anything for stdout or stderr:
>>> result = subprocess.run('echo foo', shell=True, check=True)
>>> print(result.stdout);
None
>>> print(result.stderr);
None
I also tried using capture_output=True
but I got an exception __init__() got an unexpected keyword argument 'capture_output'
, even though it is described in the documentation.
I had made a mistake, I hadn't added stdout=subprocess.PIPE
:
result = subprocess.run('echo foo', shell=True, check=True, stdout=subprocess.PIPE);
Now it's working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With