spawn* or exec* and fork, what should I use and how ?
Lingyun Yang
jing.cheng at insightbb.com
Wed Dec 15 22:00:45 EST 2004
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.
so I have to use spawn* like this:
os.spawnlp(os.P_WAIT, 'gnuplot', 'gnuplot', 'plot.tmp')
It works very well.
My question is,
1. why my exec(..) command doesn't work?
2. exec* must be with fork ?
3. In what situation, we choose one over another ?
Thank you!
regards,
Lingyun
More information about the Python-list
mailing list