I am using:
grepOut = subprocess.check_output(\"grep \" + search + \" tmp\", shell=True)
To run a terminal command, I know that I can use a
You can get the error code and results from the exception that is raised.
This can be done through the fields returncode and output.
For example:
import subprocess
try:
grepOut = subprocess.check_output("grep " + "test" + " tmp", shell=True)
except subprocess.CalledProcessError as grepexc:
print "error code", grepexc.returncode, grepexc.output