spawn syntax + os.P_WAIT mode behavior + spawn stdout redirection

Derek Basch dbasch at yahoo.com
Thu Jan 20 19:20:09 EST 2005


Hello,

*First question*

If the syntax of spawnl is:

spawnl(mode, path, ...)

Why does everyone write it like:

os.spawnlp(os.P_WAIT, 'cp', 'cp', 'index.html', '/dev/null')

or:

os.spawnl(os.P_WAIT, "/var/www/db/smm/smm_train", "smm_train",
"SMMTrainInput.xml")

How is the first 'cp' a path to a file? why does the desired executable have to
be named again as the first parameter?

*Second question*

I have a script test.py which calls another script sleep.py using a spawn.

--------------------------------------------------------------
#test.py
import os

os.spawnv(os.P_WAIT, "/var/www/db/cgi-bin/sleep.py", ["python", "sleep.py"])
#pid = os.spawnl(os.P_WAIT, 'sh', 'sh', '-cv', 'sleep 10; echo fark >
/tmp/test.out')
--------------------------------------------------------------

--------------------------------------------------------------
#sleep.py
import time

time.sleep(10)
--------------------------------------------------------------

I would expect that the test.py script should take 10sec to return. However it
returns immediatly. Perhaps I am calling the sleep.py script incorrectly?
Shouldn't it take 10sec to execute since the spawn mode argument is os.P_WAIT?

*Third question*

If I uncomment the second spawn call in test.py I do not get any output to
/tmp/test.out and it also returns immediatly. Can anyone tell me why? 

Thank You Mighty Python Guru's,
Derek Basch


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250



More information about the Python-list mailing list