os.system vs subprocess

Nate walton.nathaniel at gmail.com
Sun Jun 21 15:12:07 EDT 2009


On Jun 21, 2:12 pm, Chris Rebert <c... at rebertia.com> wrote:
> On Sun, Jun 21, 2009 at 10:12 AM, Nate<walton.nathan... at gmail.com> wrote:
> > I get different behavior with os.system and subprocess (no surprise
> > there I guess), but I was hoping for some clarification, namely why.
>
> > If I type this directly into the command window:
>
> > java -Xms128M -Xmx512M -jar gmapcreator.jar -dfile=censettings.xml >
> > mapoutput.txt
>
> > mapoutput.txt stores the output:
> > Command line mode: input file=censettings.xml
> > 1358 files will be created in C:\Documents and Settings\Nate\Desktop
> > \freqanalysis\tilefiles\CENSUS1-tiles
> > 1358 tiles created out of 1358 in 16 seconds
>
> > If I execute said command with subprocess, the output is not written
> > to mapoutput.txt - the output just appears in the command window.
>
> Show us the subprocess version of you code. People tend to not get the
> parameters quite right if they're not familiar with the library.
>
> Cheers,
> Chris
> --http://blog.rebertia.com- Hide quoted text -
>
> - Show quoted text -

Here it is:

gmapcreator = subprocess.Popen("java -Xms128M -Xmx512M -jar
gmapcreator.jar -dfile=censettings.xml", stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)



More information about the Python-list mailing list