spawn* or exec* and fork, what should I use and how ?
Jp Calderone
exarkun at divmod.com
Wed Dec 15 22:13:42 EST 2004
On Thu, 16 Dec 2004 03:00:45 GMT, Lingyun Yang <jing.cheng at insightbb.com> wrote:
>Hi,
>
> I want to use python as a "shell like" program,
> and execute an external program in it( such as mv, cp, tar, gnuplot)
> I tried:
>
> os.execv("/bin/bash",("/usr/bin/gnuplot",'-c "gnuplot < plot.tmp"'))
>
> since it's in a for-loop, it should be executed many times, but
> It exits after the first time running.
http://www.die.net/doc/linux/man/man3/execv.3.html
Note in particular this line:
The exec family of functions replaces the current process image with a new process image.
So the program is doing exactly what you asked it to. If you want to run multiple things, os.execv() is probably not for you.
Jp
More information about the Python-list
mailing list