views:

52

answers:

1

After calling an exe using python script in windows, the exe should run independent of this python script and once it is initiated the control should comeback to python script and executes the further script and control of .py file will die. But on other side before finishing execution, the exe should call this python script.

Ideas would be highly appreciated.

I have tried following commands:

  1. os.system("start test.exe")
  2. os.startfile("test.exe")
  3. os.spawnlv(os.P_NOWAIT, "test.exe")
  4. os.spawnv(os.P_NOWAIT, 'C:\Python31\python.exe', ('python', 'test.py'))
  5. os.execvp("python3", ("test.py", ))
A: 

I sounds as if you want the callee to callback the caller (sorry for the alliteration :) Since you are using Python 3.1 maybe the subprocess module will provide the intended behavior. It is not a true callback per se, but the calling program can perform decisions based on the output of the called program (exe in this case.)

jtp
You forgot the link to the documentation: http://docs.python.org/py3k/library/subprocess.html
S.Lott
@S.Lott - Ah yes. Excellent point! Thank you.
jtp