os.system vs subprocess
Christian Heimes
lists at cheimes.de
Sun Jun 21 15:49:35 EDT 2009
Nate wrote:
> gmapcreator = subprocess.Popen("java -Xms128M -Xmx512M -jar
> gmapcreator.jar -dfile=censettings.xml", stdin=subprocess.PIPE,
> stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Try this:
gmapcreator = subprocess.Popen(
["java", "-Xms128M", "-Xmx512M", "-jar", "gmapcreator.jar",
"-dfile=censettings.xml"], stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = gmapcreator.communicate("stdin input")
The subprocess doesn't use the shell so you have to apply the command as
a list of strings.
Do you really need stdin, stdout and stderr as pipes? If you aren't
carefully with the API your program can block.
Christian
More information about the Python-list
mailing list