On 14 Lug, 10:34, Peter Otten <[EMAIL PROTECTED]> 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.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to