I read up on the functions provided by subprocess - call, check_call, check_output, and understand how each works and differs in functionality from one another. I am curren
I had a similar requirement, and the following worked for me:
try:
with open ("vtcstderr.out", "w") as file:
rawOutput = subprocess.check_output(
command,
stderr=file,
shell=True
)
except subprocess.CalledProcessError as error:
# this is the stdout
rawOutput = error.output
with open ("vtcstderr.out", "r") as file:
# this is the stderr
errorLines = file.readlines()