spawn* or exec* and fork, what should I use and how ?

Peter Hansen peter at engcorp.com
Wed Dec 15 22:04:57 EST 2004


Lingyun Yang wrote:
>   I want to use python as a "shell like" program,
> and execute an external program in it( such as mv, cp, tar, gnuplot)
> 
> os.execv("/bin/bash",("/usr/bin/gnuplot",'-c "gnuplot < plot.tmp"'))

I would suggest checking out the "subprocess" module,
new in Python 2.4.  It subsumes the functionality
of most of the alternative methods such as execv and
spawn and os.system(), and provides an arguably cleaner
interface.

-Peter



More information about the Python-list mailing list