Prev: Download Proprietary Microsoft Products Now
Next: Hi, friends. I wanna ask if there is a function which is able totake a list as argument and then return its top-k maximums?
From: amit on 22 Apr 2010 16:03 How does one go about calling multiple programs using subprocess? This is the program flow: C:\> wrenv.exe C:\> make clean ... ... The 'wrenv.exe' is necessary since it sets up the proper environment for building. How do I use subprocess to execute 'wrenv.exe' and then the 'make clean' command. Any help is appreciated. Thanks, Amit
From: News123 on 22 Apr 2010 18:09 Hi Amit, As far as I know you can't really do this with subprocess, because wrenv.exe and make would be called in different contexts. THus wrenve.exe couldn't change the environment. just try following: - create a .bat file with both commands in it - verify, that the bat file works - call the bat file with Popen However I am surprised, that a .exe file can modify the current environment. At least under linux this wouldn't be possible (except with sourcing a shell script) Or do you mean with "setting up the proper environment" creating some intermediate files? bye N amit wrote: > How does one go about calling multiple programs using subprocess? > > This is the program flow: > > C:\> wrenv.exe > C:\> make clean > .. > .. > > The 'wrenv.exe' is necessary since it sets up the proper environment > for building. How do I use subprocess to execute 'wrenv.exe' and then > the 'make clean' command. > > Any help is appreciated. > > Thanks, > Amit
From: Bryan on 23 Apr 2010 05:38 amit asked: > How does one go about calling multiple programs using subprocess? > > This is the program flow: > > C:\> wrenv.exe > C:\> make clean > .. > > The 'wrenv.exe' is necessary since it sets up the proper environment > for building. How do I use subprocess to execute 'wrenv.exe' and then > the 'make clean' command. > > Any help is appreciated. In this case I don't see that you need to call multiple programs simultaneously. You call 'wrenv.exe', then when and if it completes successfully you call 'make clean'. Calling multiple programs sequentially should be straightforward. What, specifically, is going wrong? Python's subprocess module rocks on Unix, and provides some useful corresponding features that are easily available on MS Windows. If your job is to rock on Windows, don't commit to modules devoted to rockin' on Unix. Python has multiple ways to run "wrenv.exe", then "make clean". In particular, check out os.system. -- --Bryan
From: Amit Uttamchandani on 23 Apr 2010 15:51 On Thu, Apr 22, 2010 at 10:12:47PM -0400, Dave Angel wrote: > amit wrote: > >How does one go about calling multiple programs using subprocess? > > > >This is the program flow: > > > >C:\> wrenv.exe > >C:\> make clean > >.. > >.. > > > >The 'wrenv.exe' is necessary since it sets up the proper environment > >for building. How do I use subprocess to execute 'wrenv.exe' and then > >the 'make clean' command. > > > >Any help is appreciated. > > > >Thanks, > >Amit > > > One way is to write a batch file (since you're on Windows), and > execute that with shell=True. > > It's not the only way, or the most efficient. But it's most likely > to work, without knowing anything more about those two programs. > > DaveA > Thanks Dave. That's actually a good idea and in this case probably the only way that this would work. I can auto-generate the batch file from the python script with the parameters that I need and just execute that with the subprocess. I wish there was a cleaner was as well. But thanks for tip! Amit
From: Dave Angel on 22 Apr 2010 22:12
amit wrote: > How does one go about calling multiple programs using subprocess? > > This is the program flow: > > C:\> wrenv.exe > C:\> make clean > .. > .. > > The 'wrenv.exe' is necessary since it sets up the proper environment > for building. How do I use subprocess to execute 'wrenv.exe' and then > the 'make clean' command. > > Any help is appreciated. > > Thanks, > Amit > > One way is to write a batch file (since you're on Windows), and execute that with shell=True. It's not the only way, or the most efficient. But it's most likely to work, without knowing anything more about those two programs. DaveA |