Skip to Content
Python: Essential Reference, Third Edition
book

Python: Essential Reference, Third Edition

by David Beazley
February 2006
Intermediate to advanced content levelIntermediate to advanced
648 pages
14h 53m
English
Sams
Content preview from Python: Essential Reference, Third Edition

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python: Essential Reference

Python: Essential Reference

David M. Beazley

Publisher Resources

ISBN: 0672328623Purchase book