On Jul 14, 12:34 pm, 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

Thanks Peter.

Just curious

What difference does the following code makes? What are the advantages
of the above method over this one?
output = subprocess.Popen(['ls', '-l'],
stdout=subprocess.PIPE).communicate()[0]

Also could someone show an example of using the optional input
argument for communicate()

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to