popen child termination

Milos Prudek prudek at bvx.cz
Sat Aug 21 06:28:07 EDT 2004


How can I make popen (popen2, popen3) run and finish inside my program?

Example:

def Run(cmd):
     w,r,e = os.popen3(cmd)
     w.close()
     r.close()
     e.close()
Run('touch ~/xxx')
os.remove('~/xxx')

The example above fails with this error message for os.remove: "No such 
file or directory: '~/xxx'"

But when the os.remove line is deleted, the example correctly creates 
the xxx file.

I feel that os.wait() deals with this but I do not understand how to use 
it to do what I want.

-- 
Milos Prudek



More information about the Python-list mailing list