I'm trying to get the error message that is returned when a traceroute fails. For example:
from subprocess import CalledProcessError, check_output
try:
output = check_output(["traceroute", "error"])
except CalledProcessError as error:
output = error.output
print "error: {}".format(output)
Output:
error:
I've tried using output = str(error.output)
but output stays empty. An error message is printed to the terminal when executing the above code, so it should be possible to assign it to a variable, right?