Pseudo-TTY (pty module) help!
Michael Hudson
mwh at python.net
Mon Apr 15 07:24:49 EDT 2002
"Noah" <noah at noah.org> writes:
> Does anyone have any experience or samples of use of the pty module?
Not really. I've used os.openpty (or was it os.forkpty?) which are
what I think the pty module emulates when the above are not around (no
idea when this is, either).
Here's something that I got to work:
def su():
import os, tty, time
def p(d=0.2): time.sleep(d)
pid, fd = os.forkpty()
if pid == 0:
os.execlp("su","su")
else:
p()
print `os.read(fd, 1000)`
p()
os.write(fd, "XXXX\r")
p(2)
print `os.read(fd, 1000)`
I don't know if this helps!
The only other suggestions are to post some code and read Stevens'
APUE.
Cheers,
M.
--
/* I'd just like to take this moment to point out that C has all
the expressive power of two dixie cups and a string.
*/ -- Jamie Zawinski from the xkeycaps source
More information about the Python-list
mailing list