Launch file from Python

kyosohma at gmail.com kyosohma at gmail.com
Wed Aug 8 13:36:51 EDT 2007


On Aug 8, 12:28 pm, joc... at gmail.com wrote:
> Good afternoon from someone who is trying to learn Python.
>
> I would like to launch an app from within a Python script. From the
> examples I have found, I should be able to do this with os.system.
>
> I use this:
> os.system("xplanet-1.2.0/xplanet.exe -fontsize 24 -label -target earth
> -lat 33.65 -lon -84.42 -radius 40 -num_times 1 -tmpdir .")
> This is copied directly from the .bat file that launches the xplanet
> app. It works there.
>
> and get this:
> 1
>
> Can someone fill me in?  Thanks.

That's just the exit status or run status, if I recall correctly. I
think 0 (i.e. False) means it didn't run properly and anything else is
True, or ok. Something like that. Technically speaking, you should
probably switch to using the subprocess module as it is replacing that
os module's functionality: http://www.python.org/doc/2.4/lib/module-subprocess.html

This thread also discusses it somewhat:
http://www.velocityreviews.com/forums/t348777-python-doc-problem-example-ossystem.html

Mike




More information about the Python-list mailing list