Pipe subprocess standard output to a variable [duplicate]
To get the output of ls, use stdout=subprocess.PIPE. >>> proc = subprocess.Popen(‘ls’, stdout=subprocess.PIPE) >>> output = proc.stdout.read() >>> print output bar baz foo The command cdrecord –help outputs to stderr, so you need to pipe that indstead. You should also break up the command into a list of tokens as I’ve done below, or the … Read more