473,716 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("xpla net-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 2325
On Aug 8, 12:28 pm, joc...@gmail.co m 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("xpla net-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.co m 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("xpla net-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.c omwrote:
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.Pope n("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.org wrote:
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.org wrote:


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.co m <jo****@gmail.c omwrote:
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("xpla net-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.e xe 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.dyn dns.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
10813
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 and Python 2.2.2 and i see that the program is either launched as Zombie state using spawnv(), or running in State "S" sleep in spawnl( ). Here's the sample code that launches my program: os.spawnv(os.P_NOWAIT,'/usr/bin/python',('python...
4
5202
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 the exe. The exe then generates a graph based upon the input parameters. I am reading about the Process class and wondering if that is the best approach to this. Can you recommend a KB article?
0
1322
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 Microsoft Access. Nothing happens. But if no one else has the .MDB file open then Access launches without issue. things noted - some stuff obvious
5
32737
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 pass the file name (which will then result in the application associated with the file extension to launch). I want to prevent the application registered in the system as being associated with the file extension from opeing the file.
5
1997
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 (never heard of pipes). When I use a batch file, I can launch the bat-file from python, and the windows application launched from the batchfile is run perfectly.
5
1435
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 application has it's own version of Python installed with it how should I use the system Python to launch the version of Python that launches my Application. Yes, this is a convoluted process, but not all Pythons are built the same :) Right now I am...
0
819
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
6236
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 this shell script using the Subprocess module. Here is my code: def resultFromRunning_(command):
6
2626
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. The executable will crunch some data and then launch another application.
0
8823
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9344
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7980
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5969
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4477
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2119
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.