Python - subprocess - getstatusoutput

Viewed 14088

I'm new to Python and Programming as well. I know from Google's python class how to run external command using:

(status, output) = commands.getstatusoutput(cmd)
if status: ## Error case, print the command's output to stderr and exit
sys.stderr.write(output)
sys.exit(1)

But I perceive that commands module is going obsolete. I want the status and the output, so I can print the output using sys.stderr.write() if there is any error. So, is there any equivalent command in subprocess module? I'm currently using:

subprocess.call(args,shell=False) now.

Thanks!

4 Answers
Related