I'm using the subprocess
module from python and whenever I call any of the methods that subprocess has to run, in this case some bash code on the shell, the output (lets say from a command e.g iwconfig) is redirected to stderr.
Shouldn't the output from that command be redirected to stdout instead of to stderr? As I said, this happens on any method like .Popen()
and .check_output()
.
This question might seem duplicated, but I don't find any other answers on the forum that explains the concept of why this happens.
The stderr
parameter is set to subprocess.STDOUT
so I can grab the output from the command. Otherwise there is no other way. In any case, stderr is where the output errors go, right? This does not make sense for me...
s = subprocess.check_output("iwconfig", shell=True, universal_newlines=True, stderr=subprocess.STDOUT)
Thanks in advance.