subprocess module

Peter Otten __peter__ at web.de
Mon Jul 14 10:34:05 CEST 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