I wrote a program called "ptyrun", which runs an arbitrary program in a
pseudo-tty. I personally found it useful, so maybe somebody else will
find it useful also. You can find it at
http://boxen.math.washington.edu/home/jdemeyer/ptyrun/ptyrun.c
Compile this with
$ gcc -O2 -Wall -lutil ptyrun.c -o ptyrun
You use it by executing
$ ptyrun COMMAND
This executes COMMAND in a pseudo-terminal. From the outside, it looks
like COMMAND just runs normally, but COMMAND itself will see that it's
running in a pty. COMMAND will be executed through /bin/sh, so it can
be any shell command.
Since Python changes its output buffering strategies depending on
whether the output is a terminal or not, this can be used to emulate
terminal behaviour. I personally found this useful in the following
setting:
$ ./sage -t -verbose devel/sage/sage | tee test.log
Since the doctesting process (i.e. Python) does buffering, the output
will not be fluent. Instead, if you do
$ ptyrun "./sage -t -verbose devel/sage/sage" | tee test.log
the output will appear line-by-line, just as if the "tee test.log"
wasn't there.
Jeroen.
drkirkby@laptop:~$ gcc -O2 -Wall -lutil ptyrun.c -o ptyrun
ptyrun.c:33:17: fatal error: pty.h: No such file or directory
compilation terminated.
Dave
Well, I developed this program for Linux machines. I don't know what
the Solaris equivalent is for the openpty() function. Maybe there isn't
even one??
Jeroen.
> Well, I developed this program for Linux machines. I don't know what
> the Solaris equivalent is for the openpty() function. Maybe there isn't
> even one??
>
> Jeroen.
II dont' think there is one. That is part of glibc.
http://h30097.www3.hp.com/docs/transition/openpty.pdf
describes ho to implement it on HP-UX. I guess the same would work for
OS X and Solaris.
dave
Jeroen.
> Hello sage-devel,
>
> I wrote a program called "ptyrun", which runs an arbitrary program in a
> pseudo-tty. I personally found it useful, so maybe somebody else will
> find it useful also. You can find it at
> http://boxen.math.washington.edu/home/jdemeyer/ptyrun/ptyrun.c
>
> Compile this with
> $ gcc -O2 -Wall -lutil ptyrun.c -o ptyrun
FWIW, on Mac OS X (at least, 10.6), there is no "pty.h", but there is a "openpty()". Use "util.h" in place of "pty.h".
Also, there is no libutil. Just a simple "make ptyrun" will complete w/o errors (once the header change is made). I have not yet tried the program, so I don't vouch for its effectiveness on Mac OS X.
HTH
Justin
--
Justin C. Walker, Curmudgeon at Large
Institute for the Absorption of Federal Funds
-----------
I'm beginning to like the cut of his jibberish.
-----------