Skip to content

Instantly share code, notes, and snippets.

@jquast
Created March 17, 2014 05:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jquast/9594450 to your computer and use it in GitHub Desktop.
Save jquast/9594450 to your computer and use it in GitHub Desktop.
osx pty
Python 2.7.6 (default, Jan 21 2014, 22:43:59)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pty, os, termios
>>> master, slave = pty.openpty()
>>> master, slave
(3, 4)
>>> termios.tcgetattr(master)
[11010, 3, 19200, 1483, 9600, 9600, ['\x04', '\xff', '\xff', '\x7f', '\x17', '\x15', '\x12', '\xff', '\x03', '\x1c', '\x1a', '\x19', '\x11', '\x13', '\x16', '\x0f', '\x01', '\x00', '\x14', '\xff']]
>>> termios.tcgetattr(slave)
[11010, 3, 19200, 1483, 9600, 9600, ['\x04', '\xff', '\xff', '\x7f', '\x17', '\x15', '\x12', '\xff', '\x03', '\x1c', '\x1a', '\x19', '\x11', '\x13', '\x16', '\x0f', '\x01', '\x00', '\x14', '\xff']]
>>> os.isatty(master)
True
>>> os.isatty(slave)
True
>>> os.ttyname(slave)
'/dev/ttys001'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment