PTY(1)

πŸ“¦ version 93vu, in opensuse-leap 16.0

πŸ’… PTY(1) β€” the pseudo-terminal bestie you didn't know you needed πŸ’…

okay so real talk, this is pty from the Korn shell utilities, and it's literally about to make your whole terminal life make sense. buckle up bestie πŸŽ€


✨ NAME ✨

pty β€” create a pseudo terminal and run a command in it πŸ’–

🌸 SYNOPSIS 🌸

pty [ options ] command [arg ...]

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: pty creates a pseudo pty and then runs command with the arguments you passed as arg, and it hooks up the standard input, standard output, and standard error of that command to the pseudo terminal. no cap, that's the whole magic. and by default, the pty creates a new session (main character energy from the jump πŸ‘‘).

if command does not contain a /, then the PATH variable is used to locate the command β€” so it'll go hunting through your path like it's searching for the aux cord πŸ”.

input you send to pty gets written to the standard input of this command. and the standard output and standard error coming back from the command get written to the standard output of pty. clean, simple, reciprocal, we love to see it 🫢.

the pty command terminates when the command completes. it said "I'll leave when they leave" πŸ’€.

✨ OPTIONS ✨

  • -d, --dialogue β€” execute the dialogue on the standard input. a dialogue is a sequence of commands, one command per line. all re patterns are extended regular expressions. the re ?1 will print the subject string on the standard error and match the string; the re ?0 will print the subject string on the standard error and not match the string; and the re ?. matches EOF. the commands are, and yes I'm listing every single one of them because we don't skip 🫑:
    • # comment β€” a comment line
    • c text β€” write text to the master; C style escapes in text are converted, including \E for ESC and \cX for control-X
    • d milliseconds β€” set the delay before each master write to milliseconds; the default is no delay
    • i re β€” read a line from the master; if it matches re then execute lines until matching e or f
    • e [re] β€” else [if match re] then execute lines until matching e or f
    • f β€” end of i/e block
    • m text β€” write text to the standard error
    • p text β€” peek input until text is found at the beginning of a line; input is not consumed
    • r [re] β€” read a line from the master [and it should match re]
    • s milliseconds β€” sleep for milliseconds
    • t milliseconds β€” set the master read timout to milliseconds; the default is 1000
    • u re β€” read lines from the master until one matches re
    • v level β€” set the verbose trace level, more output for higher levels, disabled for level 0
    • w text β€” write text\r\n to the master; C style escapes in text are converted, including \E for ESC and \cX for control-X
    • x [code] β€” exit pty with exit code 0 [code]
    • I re β€” ignore master lines matching re
    • L label β€” prefix all diagnostics with label:
    • P text β€” delay each master write until the beginning of an unread input line exactly matches text
  • -D, --debug=level β€” set the debug trace level, higher levels produce more output, disabled for level 0.
  • -l, --log=file β€” log the master stdout and stderr to file.
  • -m, --messages=file β€” redirect diagnostic message output to file.
  • -s, --session β€” create a separate session for the process started by pty. on by default. and bestie, listen: -s means --nosession. the way that flips, iykyk πŸ™ˆ.
  • -t, --timeout=milliseconds β€” set the master read timeout to milliseconds. the default value is 1000.
  • -T, --tty=stty β€” pass stty to the stty(1) command to initialize the pty.
  • -w, --delay=milliseconds β€” set the delay before each master write to milliseconds. the default value is 0.

πŸ”₯ EXIT STATUS πŸ”₯

if the command determined by command is run, then the exit status of pty is literally that of this command. otherwise, brace yourself, the exit status is one of these:

  • 127 β€” the command is found but cannot be executed. it was right there and it still said no 😭.
  • 128 β€” the command could not be found. gone, missing, not in the building πŸ’€.

🌈 SEE ALSO 🌈

command(1), exec(1) β€” go give them a read, they're iconic too πŸ‘‘

🧚 IMPLEMENTATION 🧚

  • version β€” pty (AT&T Research) 2012-06-11
  • author β€” Glenn Fowler <gsf@research.att.com>
  • author β€” David Korn <dgk@research.att.com>
  • copyright β€” Copyright (c) 2001-2012 AT&T Intellectual Property
  • license β€” http://www.eclipse.org/org/documents/epl-v10.html

and that's the whole page bestie, no crumbs left πŸ“ this was PTY(1) from the Korn shell utilities, AT&T Research version 2012-06-11, dated 2012-08-01. now go create some pseudo terminals and slay, fr fr πŸ’…βœ¨

πŸ“¦ where this page comes from