Python implementation of pty
. ( Chapter 19 of APUE by W. Richard Stevens.)
Test in Python 3.6 and 2.7 in `4.12.8-2-ARCH GNU/Linux
pip install ppty
usage: ppty [-h] [-i] [-e] [-n] [-d DRIVER] [-v] prog [args [args ...]]
Run process in pseudoterminal
positional arguments:
prog program to run
args args to the program
optional arguments:
-h, --help show this help message and exit
-i, --ignoreeof ignore EOF on stdin
-e, --noecho noecho for slave pty
-n, --no-interactive not interactive
-d DRIVER, --driver DRIVER
driver (executable) for stdin/stdout
-v, --verbose
ppty sh
ppty -i slowout </dev/null >file.out & # monitor a slow output and long-running program in the background
ppty sh | tee typescript # simulate scirpt(1)