O'Reilly logo

Python: Essential Reference, Third Edition by David Beazley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

commands

The commands module is used to execute system commands as a string and return their output as a string. This module is only available on UNIX systems.

getoutput(cmd)

Executes cmd in a shell and returns a string containing both the standard output and standard error streams of the command.

getstatus(filename)

Returns the output of 'ls -ld filename' as a string.

getstatusoutput(cmd)

Like getoutput(), except that a 2-tuple (status, output) is returned, where status is the exit code, as returned by the os.wait() function, and output is the string returned by getoutput().

mkarg(str)

Turns str into an argument that can be safely used within a command string (using quoting rules of the shell).

Notes

  • The os.popen2() call is used to execute ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required