I am new to Python. I need to catch all the error / exceptions from subprocess.run.
Currently, I have a Python file which has subprocess.run(shell script) [ runs a shell script ]
I need to catch all the exceptions from this process,
I tried except 'Exception as e: print(e)' but couldn't see all the errors.
According to doc subprocess.check_output()_doc, you can handle the exception as follow:
try:
subprocess.run(...)
except subprocess.CalledProcessError as e:
print e.output
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