os.pipes() - need help!
Sven Drescher
Sven.Drescher at dlr.de
Tue Jul 20 05:47:41 EDT 1999
Hi!
I'm really hopeless. I tried for a week to use pipes, but nothing happend.
The information I found on the homepages and in Deja-News aren't enough for
me.
I found the following example:
#!/usr/local/bin/python
import os
import sys
#pipes definieren
pipe1 = os.pipe() # parent stdin, child stdout
pipe2 = os.pipe() # child stdin, parent stdout
pid=os.fork()
if pid:
os.close(pipe1[1]) # child stdout - close
os.close(pipe2[0]) # child stdin - close
os.dup2(pipe1[0], 0) # sys.stdin = parent stdin
os.dup2(pipe2[1], 1) # sys.stdout = parent stdout
else:
os.close(pipe1[0]) # parent stdin - close
os.close(pipe2[1]) # parent stdout - close
os.dup2(pipe2[0], 0) # sys.stdin = child stdin
os.dup2(pipe1[1], 1) # sys.stdout = child.stdout
os.execv("/usr/openwin/bin/xterm", ["xterm"])
sys.stdout.write("ls\n")
sys.stdout.flush()
So, now I don't know why nothing happens. I tried various combinations and
also print and others - no result!!!
Thanks for help!
Sven
More information about the Python-list
mailing list