Mailing List Archive

Writing data to a pty file descriptor
Pythoners,

I'm trying to write data to a pty (pseudo terminal).
I'm using the pty module (pty.writen) after forking a
child with a controlling terminal, execing the shell, etc.
(similar to what Expect does or the code in Ch.19 of
Stevens' Advanced Programming in the UNIX environment)

I'm not sure why but I can't write certain characters
to the pty. I've written the following command to the pty to set
up for a file input from the shell command line.

$ cat > file.uue << EOF
>

However, as soon as I try to write certain characters,
the shell seems to interpret them incorrectly. One
character that does this is the back-tick -- `
character. This seems odd to me since I can input
the characters from stdin just fine... but not by
writing to the pty directly.
Any ideas about why a write to the pty from python
would fail?

Aaron

--
Aaron Rhodes
aarhodes@cisco.com
(512) 378-1097
Writing data to a pty file descriptor [ In reply to ]
Quoth Aaron Rhodes <aarhodes@cisco.com>:
| I'm trying to write data to a pty (pseudo terminal).
| I'm using the pty module (pty.writen) after forking a
| child with a controlling terminal, execing the shell, etc.
| (similar to what Expect does or the code in Ch.19 of
| Stevens' Advanced Programming in the UNIX environment)
|
| I'm not sure why but I can't write certain characters
| to the pty. I've written the following command to the pty to set
| up for a file input from the shell command line.
|
| $ cat > file.uue << EOF
| >
|
| However, as soon as I try to write certain characters,
| the shell seems to interpret them incorrectly. One
| character that does this is the back-tick -- `
| character. This seems odd to me since I can input
| the characters from stdin just fine... but not by
| writing to the pty directly.
| Any ideas about why a write to the pty from python
| would fail?

Not really, but in the meantime, I think you should change
"EOF" to "'EOF'". Quote it, in other words. That would
seem to make no sense, but it's a cue to the shell that the
"here document" following is not to be subject to expansion
of variables and so forth - including `. (I don't know, you
don't really say what happens, or what "interpret them
incorrectly" means to you. The shell is interpreting them
correctly, it's your expectation that's incorrect, but if
you want the backquotes to be interpreted, then my advice
is misplaced.)

Donn Cave, University Computing Services, University of Washington
donn@u.washington.edu