commands
index
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/commands.py
Module Docs

Execute shell commands via os.popen() and return status, output.
 
Interface summary:
 
       import commands
 
       outtext = commands.getoutput(cmd)
       (exitstatus, outtext) = commands.getstatusoutput(cmd)
       outtext = commands.getstatus(file)  # returns output of "ls -ld file"
 
A trailing newline is removed from the output string.
 
Encapsulates the basic operation:
 
      pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')
      text = pipe.read()
      sts = pipe.close()
 
 [Note:  it would be nice to add functions to interpret the exit status.]

 
Functions
       
getoutput(cmd)
Return output (stdout or stderr) of executing cmd in a shell.
getstatus(file)
Return output of "ls -ld <file>" in a string.
getstatusoutput(cmd)
Return (status, output) of executing cmd in a shell.

 
Data
        __all__ = ['getstatusoutput', 'getoutput', 'getstatus']