subprocess module
sukkopera at gmail.com
sukkopera at gmail.com
Mon Jul 14 05:41:23 EDT 2008
On 14 Lug, 10:34, Peter Otten <__pete... at web.de> wrote:
> 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
Correct, but I would rather use Python's os.listdir() and/or
os.stat(). Executing a simple ls running a subprocess is overkill.
More information about the Python-list
mailing list