A history of toolsets
The earliest tool for this sort of thing was Daniel J. Bernstein's "pty" package, described by Rich Salz as a "Ginsu knife", which he wrote back at the turn of the 1990s in order to cheat at nethack (sic!). Version 4 of the "pty" package was published in 1992 to
comp.sources.unix (volume 25 issues 127 to 135). It's still locatable on the World Wide Web. Paul Vixie described it at the time:
What can I say? It slices, it dices, it washes dishes, it walks the dog. It "just works", meaning that if you follow the directions you'll get a working package without any pulling of hair or gnashing of teeth or other standard porting activities.
Bernstein later updated this, somewhen on or before 1999-04-07, with a "ptyget" package, which he announced:
I've put together a new pseudo-tty allocator, ptyget. An alpha version
There's a ptyget mailing list; to join, send an empty message to
I designed ptyget's interface from scratch. It's much more modular than
pty; the basic pty interface has now been split into three pieces:
ptyget: a tiny, low-level program — the only setuid program in the package — that allocates a new pseudo-tty and passes it to the program of your choice
ptyspawn: another small program that runs a child process under a pseudo-tty, waiting for it to exit and watching for stops
ptyio: another, only slightly larger, program that moves data back and forth
The old Ginsu knife
pty is now spelled
ptybandage, which is a
ptyget ptyio -t ptyspawn;
pty -d, for attaching
network programs to pseudo-ttys, is now spelled
ptyrun, which is a
ptyget ptyio ptyspawn; and
nobuf is a synonym for
ptyget ptyio -r ptyspawn -23x. I've split off the session management
features into a separate package.
That separate package was the "sess" package.
"ptyget" is, incidentally, notable for exemplifying a very early version of, and one of the few published instances of, Berstein's own never-published "redo" build system.
dependon is a clear precursor to
Dru Nelson publishes both "pty" version 4 and "ptyget".
Paul Jarc publishes a fixed version of ptyget, that attempts to deal with the operating-system-specific pseudo-terminal device ioctls in the original that operating systems actually no longer provide.
The nosh source package comes with workalike
ptyrun scripts, which use Laurent Bercot's
execline tool and the nosh package's own pseudo-terminal management commands.
A few example uses
Jurjgen Oskam using
ptybandage on AIX to feed input from a here document to a program that explicity opens and read its controlling terminal for a password prompt:
$ ptybandage dsmadmc <<EOF >uit.txt
Andy Bradford using
ptyrun on OpenBSD under daemontools and ucspi-tcp to make the
bgplgsh interactive router control program accessible via the network whilst making it think that it is talking to a terminal:
exec envuidgid rviews tcpserver -vDRHl0 0 23 ptyrun /usr/bin/bgplgsh