PTY(1)
π 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. allrepatterns are extended regular expressions. the re?1will print the subject string on the standard error and match the string; the re?0will 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 linec textβ writetextto the master; C style escapes intextare converted, including\Efor ESC and\cXfor control-Xd millisecondsβ set the delay before each master write tomilliseconds; the default is no delayi reβ read a line from the master; if it matchesrethen execute lines until matchingeorfe [re]β else [if matchre] then execute lines until matchingeorffβ end ofi/eblockm textβ writetextto the standard errorp textβ peek input untiltextis found at the beginning of a line; input is not consumedr [re]β read a line from the master [and it should matchre]s millisecondsβ sleep formillisecondst millisecondsβ set the master read timout tomilliseconds; the default is1000u reβ read lines from the master until one matchesrev levelβ set the verbose trace level, more output for higher levels, disabled for level0w textβ writetext\r\nto the master; C style escapes intextare converted, including\Efor ESC and\cXfor control-Xx [code]β exitptywith exit code0[code]I reβ ignore master lines matchingreL labelβ prefix all diagnostics withlabel:P textβ delay each master write until the beginning of an unread input line exactly matchestext
-D,--debug=levelβ set the debug trace level, higher levels produce more output, disabled for level0.-l,--log=fileβ log the master stdout and stderr tofile.-m,--messages=fileβ redirect diagnostic message output tofile.-s,--sessionβ create a separate session for the process started bypty. on by default. and bestie, listen:-smeans--nosession. the way that flips, iykyk π.-t,--timeout=millisecondsβ set the master read timeout tomilliseconds. the default value is1000.-T,--tty=sttyβ passsttyto thestty(1)command to initialize the pty.-w,--delay=millisecondsβ set the delay before each master write tomilliseconds. the default value is0.
π₯ 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
- opensuse-leap 16.0: ksh 93vu-bp160.1.33 Β· CPL-1.0 AND EPL-1.0
- opensuse-leap 16.0: ksh 93vu-bp160.1.33 Β· CPL-1.0 AND EPL-1.0
- opensuse-leap 16.0: ksh 93vu-bp160.1.33 Β· CPL-1.0 AND EPL-1.0
- opensuse-leap 16.0: ksh 93vu-bp160.1.33 Β· CPL-1.0 AND EPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms