473,320 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Launch file from Python

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.

Aug 8 '07 #1
7 2306
On Aug 8, 12:28 pm, joc...@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/mo...ubprocess.html

This thread also discusses it somewhat:
http://www.velocityreviews.com/forum...-ossystem.html

Mike

Aug 8 '07 #2
On Aug 8, 1:36 pm, kyoso...@gmail.com wrote:
On Aug 8, 12:28 pm, joc...@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/mo...ubprocess.html

This thread also discusses it somewhat:http://www.velocityreviews.com/forum...c-problem-exam...

Mike
The application, however, never runs. I'll give the sub-process a
shot. Thanks.

Aug 8 '07 #3
On Aug 8, 1:11 pm, jocago <joc...@gmail.comwrote:
The application, however, never runs. I'll give the sub-process a
shot. Thanks.
Well, that's a problem. I suppose the best thing to try is use some
smaller sets of flags and see if they work. Instead of your long
string, try something smaller, like:

subprocess.Popen("xplanet-1.2.0/xplanet.exe -fontsize 24 -label -
target earth", shell=True)

Once you've gotten it to work on a smaller scale, you should be able
to work your way up.

Mike

Aug 8 '07 #4
ky******@gmail.com escribió:
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.
The other way: 0 means "ok" while everything else means error (at least in
UNIX). The reason is clear: there is usually only one way to do things well, but
many to fail :-)
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/mo...ubprocess.html
Correct, subprocess replaces low-level os.system, os.popen*, os.spawn*, popen*
functions.
Aug 8 '07 #5
On Aug 8, 2:35 pm, Arnau Sanchez <ar...@ehas.orgwrote:
kyoso...@gmail.com escribió:
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.

The other way: 0 means "ok" while everything else means error (at least in
UNIX). The reason is clear: there is usually only one way to do things well, but
many to fail :-)
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/mo...ubprocess.html

Correct, subprocess replaces low-level os.system, os.popen*, os.spawn*, popen*
functions.
Figures...I couldn't find the docs on it though...and I do know that
some Windows programs return goofy numbers in the 1000s that mean it
worked fine. So, in other words, the return value isn't very helpful.

Mike

Aug 8 '07 #6
On Aug 8, 2:39 pm, kyoso...@gmail.com wrote:
On Aug 8, 2:35 pm, Arnau Sanchez <ar...@ehas.orgwrote:


kyoso...@gmail.com escribió:
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.
The other way: 0 means "ok" while everything else means error (at leastin
UNIX). The reason is clear: there is usually only one way to do things well, but
many to fail :-)
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/mo...ubprocess.html
Correct, subprocess replaces low-level os.system, os.popen*, os.spawn*,popen*
functions.

Figures...I couldn't find the docs on it though...and I do know that
some Windows programs return goofy numbers in the 1000s that mean it
worked fine. So, in other words, the return value isn't very helpful.

Mike- Hide quoted text -

- Show quoted text -

I had used popen on windows and had to seperate the arguments out..
(example is in my awk module in dex tracker on sourceforge).. What
you did may not work on windows.

Aug 9 '07 #7
On Wed, 08 Aug 2007 10:28:57 -0700, jo****@gmail.com <jo****@gmail.comwrote:
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!
Aug 12 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: nushin | last post by:
Try to launch a test program that prints hello world for a minute or so using, spawnv( ) or spawnl( ). Check to see the process state code that the program is running. I am using RedHat Linux 7.3...
4
by: Caroline | last post by:
I'd like to launch an executable file from a web page. Basically, the user enters seven parameters and then clicks a button to generate a graph. The input is written to a file and then read by...
0
by: Matt Fox | last post by:
All, After installing sp2 I have this issue where if I try to launch an .MDB (Access database) file off any network share through explorer, that is open by multiple users, it will not launch...
5
by: GrantS | last post by:
Hi I am trying to use ShellExecute to launch an application to display a certain file. The variation on the theme is that I need to be able to specify the application to launch and not simply...
5
by: stef mientki | last post by:
hello, I'm trying to launch a windows application, but as many others on this list, I've some trouble. I read some other threads about this topic, but sorry, I still don't understand all this...
5
by: aha | last post by:
Hello All, I have a situation where I can count on a Python installation being available on a system, but I can't count on it being a version of Python needed by my application. Since my...
0
by: Ivan Ven Osdel | last post by:
>Hello All, Simplest case: Obviously things can be shortened by adding to the PATH. Ivan Ven Osdel Software Engineer
7
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke...
6
by: tempnode | last post by:
I have a problem that I can't seem to solve: I need to write a C++ app that will run off of a floppy. Basically, I will boot into DOS (from a floppy), and run my executable from the floppy. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.