Sunday, April 18, 2010

using the subprocess module

I was trying to automate some task involving shell programs, which actually a handful to type. As a lazy programmer, AUTOMATE WE MUST. Just turn out it involve with virtualenv, or rather virtualenv bootstrap script(that is another story altogether). So I do it in python. 

One of the thing added in python 2.6 is the subprocess module. To start use it

import subprocess

to use it, after the import, run this['programname','parameter1','parameter2'......])

for example to call some unix command['ls','-l'])['ps','-aux'])

or in my case, i use it to run in bootstrap script for virtualenv['python','','install'])['easy_install','-U','packagename'])

Just a little writeup of subprocess, probably gonna use this a lot

No comments:

Post a Comment