Launch file from Python

Jorgen Grahn grahn+nntp at snipabacken.dyndns.org
Sun Aug 12 13:44:48 EDT 2007


On Wed, 08 Aug 2007 10:28:57 -0700, jocago at gmail.com <jocago 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

That means "error", as others noted.

It is odd that you get no printouts. Had this been on Unix, you'd
either get "file not found" or similar from the shell trying to run
the thing, or something from xplanet itself (only really badly
programs return failure without printing some kind of cause).

Two more comments, assuming you are on Windows (you mention ".bat
files"):

- You use the relative path xplanet-1.2.0/xplanet.exe. That should
  require your program to have the parent of xplanet-1.2.0 as current
  directory. Did the .bat script change directory first?

- It is unusual to use / as a path separator on Windows --
  xplanet-1.2.0\xplanet.exe is more normal. Some parts of Windows
  tolerate both, others do not, IIRC.  But Python itself should not
  care in this case.

/Jorgen

-- 
  // Jorgen Grahn <grahn@        Ph'nglui mglw'nafh Cthulhu
\X/     snipabacken.dyndns.org>  R'lyeh wgah'nagl fhtagn!



More information about the Python-list mailing list