L
Lingyun Yang
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
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