473,498 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

maybe a popen question... or something else?

Working on Windows XP
Say I have a Windows executable, foo.exe.
foo.exe is a command line tool that can take a number of different
arguments and perform corresponding actions.

I want to invoke foo.exe from a Python script (using whatever will
work best). I want to continuously pass arguments to foo.exe in
between doing other stuff from within my Python script.

Some pseudo code:

processHandle = invoke("foo.exe") # what python module should "invoke"
be here?

doUnrelatedStuff()

processHandle.passArgs("arg1 arg2") # The same foo.exe I invoked above
gets these args for processing

doMoreUnrelatedStuff()

processHandle.passArgs("arg3 arg4") # The same foo.exe I invoked above
gets these args for processing

processHandle.close() # "foo.exe is destroyed"

Thanks for any help.

Aug 6 '07 #1
2 1049
dude wrote:
Working on Windows XP
Say I have a Windows executable, foo.exe.
foo.exe is a command line tool that can take a number of different
arguments and perform corresponding actions.

I want to invoke foo.exe from a Python script (using whatever will
work best). I want to continuously pass arguments to foo.exe in
between doing other stuff from within my Python script.

Some pseudo code:

processHandle = invoke("foo.exe") # what python module should "invoke"
be here?

doUnrelatedStuff()

processHandle.passArgs("arg1 arg2") # The same foo.exe I invoked above
gets these args for processing

doMoreUnrelatedStuff()

processHandle.passArgs("arg3 arg4") # The same foo.exe I invoked above
gets these args for processing

processHandle.close() # "foo.exe is destroyed"

Thanks for any help.
When you say "pass arguments", the methodology you outline definitely
isn't going to fly with argument passing. When a command is invoked the
arguments are taken from the command line, so it isn't possible to pass
further arguments at a later time.

You probably need to write to you sub-process's standard input stream.
which you can do whit the subprocess module (the modern way to do it) or
one of the various popen() functions.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
Aug 6 '07 #2
dude wrote:
Working on Windows XP
Say I have a Windows executable, foo.exe.
foo.exe is a command line tool that can take a number of different
arguments and perform corresponding actions.

I want to invoke foo.exe from a Python script (using whatever will
work best). I want to continuously pass arguments to foo.exe in
between doing other stuff from within my Python script.

Some pseudo code:

processHandle = invoke("foo.exe") # what python module should "invoke"
be here?

doUnrelatedStuff()

processHandle.passArgs("arg1 arg2") # The same foo.exe I invoked above
gets these args for processing

doMoreUnrelatedStuff()

processHandle.passArgs("arg3 arg4") # The same foo.exe I invoked above
gets these args for processing

processHandle.close() # "foo.exe is destroyed"

Thanks for any help.
When you say "pass arguments", the methodology you outline definitely
isn't going to fly with argument passing. When a command is invoked the
arguments are taken from the command line, so it isn't possible to pass
further arguments at a later time.

You probably need to write to you sub-process's standard input stream.
which you can do whit the subprocess module (the modern way to do it) or
one of the various popen() functions.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

Aug 6 '07 #3

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

Similar topics

2
4299
by: Stuart McGraw | last post by:
When I run (Python 2.3.3) this script on a MS Windows 2000 machine: import os print "1st popen..." f = os.popen ("echo " + u"\u0054\u0045\u0053\u0054.txt") print f.read () print "2nd popen..."...
6
1834
by: Robin Siebler | last post by:
I have a bunch of command line tests that I need to automate. I've run into too many bugs with the default Win2k command shell, so I need to either purchase 4NT or handle the logic and output...
4
5047
by: Ivo Woltring | last post by:
Hi Pythoneers, I am trying to make my own gui for mencoder.exe (windows port of the terrific linux mencoder/mplayer) to convert divx to Pocket_PC size. My current app creates a batch script to...
1
2765
by: sam | last post by:
Hi, I try to use popen execute scp, when the user finish password, it will return to the cin input prompt, but the problem is popen does not wait for user finish typing up the password before...
5
5893
by: damacy | last post by:
hello, everyone. i am trying to write a program which executes SQL commands stored in ..sql files. i wrote a function called psql() whose contents look like the following. .......
2
1738
by: CFAN | last post by:
Why the disk space keep on decreasing,is that due to use popen()? I have wrote a monitor program to ensure my program on working by using popen to use 'ps' command, but the disk space keep on...
3
7762
by: Jesse | last post by:
Hi all, I have a problem using wget and Popen. I hope someone can help. -- Problem -- I want to use the command: wget -nv -O "dir/cpan.txt" "http://search.cpan.org" and capture all it's...
12
10960
by: Eric_Dexter | last post by:
I am trying to modify a programming example and I am coming up with two problems... first is that I can't seem to pass along the arguments to the external command (I have been able to do that with...
1
8530
by: Mark Shewfelt | last post by:
Hello, I am attempting to use Popen() in a Windows service. I have a small Win32 .exe that I normally run through the os.popen2() function. I've written a class to work with the input and output...
0
7125
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,...
0
7002
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...
0
7165
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,...
1
6887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5462
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,...
0
3093
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...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
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...

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.