I am trying to automate a couple of steps I have to do repeatedly on windows, like open command prompt and starting virtualenv and then launching idlex. I am writing a python script which I can double click to automatically perform both these steps. I read this answer but couldn't understand it. Below is the script I have written where I am making two calls to Popen
import subprocess
#launches virtualenv in command prompt
proc1 = subprocess.Popen('start\
"IDLE"\
/d c:\\Python27\\fp\
/wait\
C:\\Python27\\fp\\Scripts\\activate.bat',
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
#starts idlex
proc2 = subprocess.Popen('start\
"IDLE"\
/B\
/d c:\\Python27\\fp\
/wait\
c:\\Python27\\fp\\scripts\\python.exe\
C:\\Python27\\fp\\Scripts\\idlex.py',
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
I want to perform both these steps without making second Popen call, but communicate() isn't working and I don't understand why. Is it because start
spawns another process whose handle isn't available?