subprocess.Popen doesn't work when args is sequence

Posted by pero on Stack Overflow See other posts from Stack Overflow or by pero
Published on 2010-03-08T11:24:23Z Indexed on 2010/03/08 12:21 UTC
Read the original article Hit count: 641

Filed under:
|

I'm having a problem with subprocess.Popen when args parameter is given as sequence.

For example:

import subprocess
maildir = "/home/support/Maildir"

This works (it prints the correct size of /home/support/Maildir dir):

size = subprocess.Popen(["du -s -b " + maildir], shell=True,
                        stdout=subprocess.PIPE).communicate()[0].split()[0]
print size

But, this doesn't work (try it):

size = subprocess.Popen(["du", "-s -b", maildir], shell=True,
                        stdout=subprocess.PIPE).communicate()[0].split()[0]
print size

What's wrong?

© Stack Overflow or respective owner

Related posts about python

Related posts about subprocess