473,386 Members | 1,810 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,386 software developers and data experts.

Howto Launch a windows application ?

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.

Now when I try to run the same windows application from Popen or call,
nothing happens (or at least it's very fast and produces not the
expected output).

Please enlighten me, preferable in "windows-terminology" ;-)

thanks,
Stef Mientki

from subprocess import *

cmd =[]
cmd.append ( 'D:\\PIC-tools\\JALxxx\\jalv2_3.exe' )
cmd.append ( '-long-start' )
cmd.append ( '-d')
cmd.append ( '-clear' )
cmd.append ( '-sD:\\PIC-tools\\JAL\\libs2' )
cmd.append ( 'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.ja l' )
cmd.append ( '>d:\\data_actueel\\d7_test_browser\\temp.log' )

# DOESN'T WORK
result = call ( cmd )

# Both Popen and call work
cmd = [ 'd:\\data_actueel\\d7_test_browser\\JALcc.bat' ]
#output = Popen ( cmd )
result = call ( cmd )
print result

Oct 3 '07 #1
5 1981

stef mientki wrote:
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.

Now when I try to run the same windows application from Popen or call,
nothing happens (or at least it's very fast and produces not the
expected output).

Please enlighten me, preferable in "windows-terminology" ;-)

thanks,
Stef Mientki

from subprocess import *

cmd =[]
cmd.append ( 'D:\\PIC-tools\\JALxxx\\jalv2_3.exe' )
cmd.append ( '-long-start' )
cmd.append ( '-d')
cmd.append ( '-clear' )
cmd.append ( '-sD:\\PIC-tools\\JAL\\libs2' )
cmd.append ( 'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.ja l' )
cmd.append ( '>d:\\data_actueel\\d7_test_browser\\temp.log' )

# DOESN'T WORK
result = call ( cmd )

# Both Popen and call work
cmd = [ 'd:\\data_actueel\\d7_test_browser\\JALcc.bat' ]
#output = Popen ( cmd )
result = call ( cmd )
print result
My guess is that with the redirect you simple need to set the 'shell'
option to true.

call(cmd, shell=True)

I haven't tested it, but it is worth a try.

Matt

Oct 3 '07 #2
stef mientki wrote:
cmd =[]
cmd.append ( 'D:\\PIC-tools\\JALxxx\\jalv2_3.exe' )
cmd.append ( '-long-start' )
cmd.append ( '-d')
cmd.append ( '-clear' )
cmd.append ( '-sD:\\PIC-tools\\JAL\\libs2' )
cmd.append (
'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.ja l' )
cmd.append ( '>d:\\data_actueel\\d7_test_browser\\temp.log' )
Your problem is probably the last line there with the '>'. That's an
output redirection that is done not by jalv2_3.exe but by the command
shell. That's why it works only with the batch file (which is
interpreted by the command shell.

Using a batch file is probably easiest for this. But I'm guessing you
probably want to change the command line arguments passed to the program
that's why you prefer to build the command line manually.

In that case, there are a few solutions:
1) Generate the batch file programmatically.
2) Use cmd.exe /C (assuming you're on Windows XP). So your program would
be something like:
cmd.append('cmd.exe')
cmd.append('/C')
cmd.append('"D:\\PIC-tools\\JALxxx\\jalv2_3.exe -long-start -d -clear
-sD:\\PIC-tools\\JAL\\libs2
d:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.ja l
>d:\\data_actueel\\d7_test_browser\\temp.log"')
(or something like that)
3) Do the redirection yourself. Remove the line:
cmd.append ('>d:\\data_actueel\\d7_test_browser\\temp.log' )
and instead read the results directly from the Popen.stdout. You can
then write the output to a file if you want.
Oct 3 '07 #3
Yu-Xi Lim wrote:
stef mientki wrote:
>cmd =[]
cmd.append ( 'D:\\PIC-tools\\JALxxx\\jalv2_3.exe' )
cmd.append ( '-long-start' )
cmd.append ( '-d')
cmd.append ( '-clear' )
cmd.append ( '-sD:\\PIC-tools\\JAL\\libs2' )
cmd.append (
'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.ja l' )
cmd.append ( '>d:\\data_actueel\\d7_test_browser\\temp.log' )

Your problem is probably the last line there with the '>'. That's an
output redirection that is done not by jalv2_3.exe but by the command
shell. That's why it works only with the batch file (which is
interpreted by the command shell.

No that's not the problem,
leaving the redirection away,
gives the same problems.
Using a batch file is probably easiest for this.
I think indeed that's he simplest solution.
Still wonder why launching a windows program is "so difficult" in python
;-)

thanks,
Stef Mientki
But I'm guessing you
probably want to change the command line arguments passed to the program
that's why you prefer to build the command line manually.

In that case, there are a few solutions:
1) Generate the batch file programmatically.
2) Use cmd.exe /C (assuming you're on Windows XP). So your program would
be something like:
cmd.append('cmd.exe')
cmd.append('/C')
cmd.append('"D:\\PIC-tools\\JALxxx\\jalv2_3.exe -long-start -d -clear
-sD:\\PIC-tools\\JAL\\libs2
d:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.ja l
>d:\\data_actueel\\d7_test_browser\\temp.log"')
(or something like that)
3) Do the redirection yourself. Remove the line:
cmd.append ('>d:\\data_actueel\\d7_test_browser\\temp.log' )
and instead read the results directly from the Popen.stdout. You can
then write the output to a file if you want.
Oct 4 '07 #4
Matimus wrote:
stef mientki wrote:
>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.

Now when I try to run the same windows application from Popen or call,
nothing happens (or at least it's very fast and produces not the
expected output).

Please enlighten me, preferable in "windows-terminology" ;-)

thanks,
Stef Mientki

from subprocess import *

cmd =[]
cmd.append ( 'D:\\PIC-tools\\JALxxx\\jalv2_3.exe' )
cmd.append ( '-long-start' )
cmd.append ( '-d')
cmd.append ( '-clear' )
cmd.append ( '-sD:\\PIC-tools\\JAL\\libs2' )
cmd.append ( 'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.ja l' )
cmd.append ( '>d:\\data_actueel\\d7_test_browser\\temp.log' )

# DOESN'T WORK
result = call ( cmd )

# Both Popen and call work
cmd = [ 'd:\\data_actueel\\d7_test_browser\\JALcc.bat' ]
#output = Popen ( cmd )
result = call ( cmd )
print result

My guess is that with the redirect you simple need to set the 'shell'
option to true.

call(cmd, shell=True)

I haven't tested it, but it is worth a try.

thanks, I tried, but it didn't work.

cheers,
Stef
Matt

Oct 4 '07 #5
On Oct 3, 5:39 pm, stef mientki <stef.mien...@gmail.comwrote:
>
from subprocess import *

cmd =[]
cmd.append ( 'D:\\PIC-tools\\JALxxx\\jalv2_3.exe' )
cmd.append ( '-long-start' )
cmd.append ( '-d')
cmd.append ( '-clear' )
cmd.append ( '-sD:\\PIC-tools\\JAL\\libs2' )
cmd.append ( 'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.ja l' )
cmd.append ( '>d:\\data_actueel\\d7_test_browser\\temp.log' )
This is sort of aside from your original question, but I should also
point out how unnecessary all those 'cmd.append's are. You can
initialize the list all at once simply like so:

cmd =['D:\\PIC-tools\\JALxxx\\jalv2_3.exe',
'-long-start',
'-d',
'-clear',
'-sD:\\PIC-tools\\JAL\\libs2',
'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.ja l',
'>d:\\data_actueel\\d7_test_browser\\temp.log']

Hyuga

Oct 8 '07 #6

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

Similar topics

7
by: dan glenn | last post by:
I want to use some javascript to launch a windows application (this used on intranet) but don't know how. Can anyone help me out please? It'd be neat if I could not only launch the application...
1
by: Michael Howes | last post by:
I have a c# windows form that talks to a web service on a server that then can talk to multiple "agents" on different machines using web service calls. I want to be able to launch an application...
7
by: Paul | last post by:
Hi. I need to launch a windows application and then send keyboard event to this process to run certain commands. I've created a COM+ appplication to spawn and talk to the application which works...
7
by: arkam | last post by:
Well everything is in the title ! Arkam
8
by: Paul | last post by:
I have looked and looked for this info. All the I/O examples I've found either explicity use a file name or use the OpenFileDialog. When you drag a MS Word document over MS Word, it launches and...
4
by: Joe | last post by:
I created a CustomAction for this but I don't think I have it in the right place. I tried both Install and Commit but neither allow it to get to the final screen. Are there any examples of this...
5
by: cooltoriz | last post by:
Hello there, I am not asking how to impersonate a process within C# windows application. I already know that, in C# v2.0, you can easily achieve it using ProcessStartInfo. You can run a process...
2
by: JDeats | last post by:
When a user double clicks on file item in Windows Explorer, Windows tries to open the document with whatever application is related to it's file extension. In my WinForms application I would...
2
by: dmitrey | last post by:
Hi all, here is a question already mentioned below, and I'm also interested in that one very much. unfortunatly, I can't write anything to matplotlib mailing lists because I constantly get server...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.