popen / batchfile / environment variables

Trent Mick trentm at ActiveState.com
Tue Nov 19 14:40:55 EST 2002


[Achim Domma wrote]
> Hello,
> 
> I want to write a python script with automaticaly builds a VC.Net solution.
> To make VS.Net usable from commandline, I first have to execute a batchfile
> which sets the required environment variables. In a Dos-Box I would do
> something like this:
> 
> path_to\vcvars32.bat
> devenv solution_file.sln /rebuild "Release"
> 
> If I use popen or system to do the same, every call runs in his own
> environment, so the changes made by the .bat file do not change the settings
> for the second call.
> 
> Any idea how to do that in python?

1. run this:
    path_to\vcvars32.bat && devenv solution_file.sln /rebuild "Release"

2. create a wrapper batch file with those two lines and run the new
   batch file:
        ---- temp.bat -------
        path_to\vcvars32.bat
        devenv solution_file.sln /rebuild "Release"
        ---------------------
   
   fout = os.popen('temp.bat')


Cheers,
Trent

-- 
Trent Mick
TrentM at ActiveState.com




More information about the Python-list mailing list