By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,957 Members | 1,960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,957 IT Pros & Developers. It's quick & easy.

maybe a popen question... or something else?

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.