maybe a popen question... or something else?

D

dude

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

Steve Holden

dude said:
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 -------------
 
S

Steve Holden

dude said:
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 -------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top