maybe a popen question... or something else?

Steve Holden steve at holdenweb.com
Tue Aug 7 01:22:12 CEST 2007


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 -------------




More information about the Python-list mailing list