p = subprocess.Popen("path to batch file")
time.sleep(30)
#do something to terminate the .exe process
I am using Popen to run a batch file. The associated program .exe opens & runs in a cmd terminal. The program can be (nicely) terminated by manually entering a 'q' argument in the terminal.
I would like to use the above python27 script to pass a 'q' string to the terminal, such that the program recognizes its native termination signal and closes out. After reading around the "os" & "subprocess" module docs & having tried several methods (.call, .terminate, .kill) I haven't had success
Edit:
The operation..
p.send_signal('q')
..seems to be what I want to do. However, 'q' raises a ValueError in the interpreter.