subprocess.getstatusoutput()

subprocess.getstatusoutput(cmd)

Return (status, output) of executing cmd in a shell.

Execute the string cmd in a shell with Popen.check_output() and return a 2-tuple (status, output). Universal newlines mode is used; see the notes on Frequently Used Arguments for more details.

A trailing newline is stripped from the output. The exit status for the command can be interpreted according to the rules for the C function wait(). Example:

>>> subprocess.getstatusoutput('ls /bin/ls')
(0, '/bin/ls')
>>> subprocess.getstatusoutput('cat /bin/junk')
(256, 'cat: /bin/junk: No such file or directory')
>>> subprocess.getstatusoutput('/bin/junk')
(256, 'sh: /bin/junk: not found')

Availability: POSIX & Windows

Changed in version 3.3.4: Windows support added

doc_python
2016-10-07 17:43:34
Comments
Leave a Comment

Please login to continue.