I’d like to have a method to do 3 things at the same time:
-
Create a subprocess that run the vsvars32.bat (visual studio batch file)
-
In this subprocess set the environment variables.For example in a cmd lines:
- SET MYDIR = C:\This\this\here
- SET DIR = %MYDIR%
- SET PATH = %DIR%\bin;%PATH%
-
Also into this subprocess call the perl script with his parameters. in cmd:
- cd %MYDIR%\SOURCE\FILES
- My_Perl.pl -Name Mac -owner -details -vs_version 2005 -Run_type rebuild
I created a code in python:
myenv = {‘MYDIR’ : ‘C:\This\this\here’,
‘DIR’ : ‘%MYDIR%’,
‘PATH’ : ‘%DIR%\bin;%PATH%’}batchCmd = ‘c:/…/vsvars32.bat’
perlCmd = ‘c:/…/MyPerl.pl’
perlValues = [‘-Name’, ‘Mac’, ‘-owner’, ‘-details’, ‘-vs_version’, ‘2005’, ‘-Run_type’, ‘rebuild’]
process = subprocess.Popen([‘cmd’,’/c’, batchCmd ,’&&’, perlCmd, perlValues], shell=False, stdin = subprocess.PIPE, stdout = subprocess.PIPE, env = myenv)
The problem is that the function subprocess.popen not recognize myenv values and the perlValues.
Try adding perl.exe to perl cmd.
Second, you use backslash for path in one place, slash in the other. That maybe a problem.
Simply try to print out the env, to see that the environment is populated or not:
Also, you forgot to cd before executing perl script.
regards,