subprocess module

Peter Otten __peter__ at web.de
Mon Jul 14 04:34:05 EDT 2008


John Mechaniks wrote:

> from subprocess import call
> call(['ls', '-l'])
> 
> How do I get the result (not the exit status of the command) of "ls -
> l" into a variable?

output = subprocess.Popen(["ls", "-l"], stdout=subprocess.PIPE).stdout.read()

Peter



More information about the Python-list mailing list