[code.view]

[top] / python / PyMOTW / subprocess / subprocess_check_output.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
     #
     """Capture the output of a command and test its exit code at the same time.
     """
     #end_pymotw_header
     
     import subprocess
     
     output = subprocess.check_output(['ls', '-1'])
     print 'Have %d bytes in output' % len(output)
     print output
     
                                       
     

[top] / python / PyMOTW / subprocess / subprocess_check_output.py

contact | logmethods.com