import subprocess command = ['ls', '-a'] print ' '.join(command) try: print subprocess.check_output(command, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: print 'There was an error when running the command:' print e.output
This runs an external program an gets its output and errors.
subprocess.check_output(*popenargs, **kwargs)
No comments:
Post a Comment