1IO::Stty(3) User Contributed Perl Documentation IO::Stty(3)
2
3
4
6 IO::Stty - Change and print terminal line settings
7
9 # calling the script directly
10 stty.pl [setting...]
11 stty.pl {-a,-g,-v,--version}
12
13 # Calling Stty module
14 use IO::Stty;
15 IO::Stty::stty(\*TTYHANDLE, @modes);
16
17 use IO::Stty;
18 $old_mode=IO::Stty::stty(\*STDIN,'-g');
19
20 # Turn off echoing.
21 IO::Stty::stty(\*STDIN,'-echo');
22
23 # Do whatever.. grab input maybe?
24 $read_password = <>;
25
26 # Now restore the old mode.
27 IO::Stty::stty(\*STDIN,$old_mode);
28
29 # What settings do we have anyway?
30 print IO::Stty::stty(\*STDIN,'-a');
31
33 This is the PERL POSIX compliant stty.
34
36 This has not been tailored to the IO::File stuff but will work with it
37 as indicated. Before you go futzing with term parameters it's a good
38 idea to grab the current settings and restore them when you finish.
39
40 stty accepts the following non-option arguments that change aspects of
41 the terminal line operation. A `[-]' before a capability means that it
42 can be turned off by preceding it with a `-'.
43
45 Control settings
46 [-]parenb
47 Generate parity bit in output and expect parity bit in input.
48
49 [-]parodd
50 Set odd parity (even with `-').
51
52 cs5 cs6 cs7 cs8
53 Set character size to 5, 6, 7, or 8 bits.
54
55 [-]hupcl [-]hup
56 Send a hangup signal when the last process closes the tty.
57
58 [-]cstopb
59 Use two stop bits per character (one with `-').
60
61 [-]cread
62 Allow input to be received.
63
64 [-]clocal
65 Disable modem control signals.
66
67 Input settings
68 [-]ignbrk
69 Ignore break characters.
70
71 [-]brkint
72 Breaks cause an interrupt signal.
73
74 [-]ignpar
75 Ignore characters with parity errors.
76
77 [-]parmrk
78 Mark parity errors (with a 255-0-character sequence).
79
80 [-]inpck
81 Enable input parity checking.
82
83 [-]istrip
84 Clear high (8th) bit of input characters.
85
86 [-]inlcr
87 Translate newline to carriage return.
88
89 [-]igncr
90 Ignore carriage return.
91
92 [-]icrnl
93 Translate carriage return to newline.
94
95 [-]ixon
96 Enable XON/XOFF flow control.
97
98 [-]ixoff
99 Enable sending of stop character when the system input buffer is
100 almost full, and start character when it becomes almost empty
101 again.
102
103 Output settings
104 [-]opost
105 Postprocess output.
106
107 Local settings
108 [-]isig
109 Enable interrupt, quit, and suspend special characters.
110
111 [-]icanon
112 Enable erase, kill, werase, and rprnt special characters.
113
114 [-]echo
115 Echo input characters.
116
117 [-]echoe, [-]crterase
118 Echo erase characters as backspace-space-backspace.
119
120 [-]echok
121 Echo a newline after a kill character.
122
123 [-]echonl
124 Echo newline even if not echoing other characters.
125
126 [-]noflsh
127 Disable flushing after interrupt and quit special characters.
128
129 * Though this claims non-posixhood it is supported by the perl
130 POSIX.pm.
131
132 [-]tostop (np)
133 Stop background jobs that try to write to the terminal.
134
135 Combination settings
136 ek Reset the erase and kill special characters to their default
137 values.
138
139 sane
140 Same as:
141
142 cread -ignbrk brkint -inlcr -igncr icrnl -ixoff opost
143 isig icanon echo echoe echok -echonl -noflsh -tostop
144
145 also sets all special characters to their default values.
146
147 [-]cooked
148 Same as:
149
150 brkint ignpar istrip icrnl ixon opost isig icanon
151
152 plus sets the eof and eol characters to their default values if
153 they are the same as the min and time characters. With `-', same
154 as raw.
155
156 [-]raw
157 Same as:
158
159 -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr
160 -icrnl -ixon -ixoff -opost -isig -icanon min 1 time 0
161
162 With `-', same as cooked.
163
164 [-]pass8
165 Same as:
166
167 -parenb -istrip cs8
168
169 With `-', same as parenb istrip cs7.
170
171 dec Same as:
172
173 echoe echoctl echoke -ixany
174
175 Also sets the interrupt special character to Ctrl-C, erase to Del,
176 and kill to Ctrl-U.
177
178 Special characters
179 The special characters' default values vary from system to system. They
180 are set with the syntax `name value', where the names are listed below
181 and the value can be given either literally, in hat notation (`^c'), or
182 as an integer which may start with `0x' to indicate hexadecimal, `0' to
183 indicate octal, or any other digit to indicate decimal. Giving a value
184 of `^-' or `undef' disables that special character.
185
186 intr
187 Send an interrupt signal.
188
189 quit
190 Send a quit signal.
191
192 erase
193 Erase the last character typed.
194
195 kill
196 Erase the current line.
197
198 eof Send an end of file (terminate the input).
199
200 eol End the line.
201
202 start
203 Restart the output after stopping it.
204
205 stop
206 Stop the output.
207
208 susp
209 Send a terminal stop signal.
210
211 Special settings
212 min N
213 Set the minimum number of characters that will satisfy a read until
214 the time value has expired, when <E>-icanon<E> is set.
215
216 time N
217 Set the number of tenths of a second before reads time out if the
218 min number of characters have not been read, when -icanon is set.
219
220 N Set the input and output speeds to N. N can be one of: 0 50 75 110
221 134 134.5 150 200 300 600 1200 1800 2400 4800 9600 19200 38400 exta
222 extb. exta is the same as 19200; extb is the same as 38400. 0
223 hangs up the line if -clocal is set.
224
225 OPTIONS
226 -a Print all current settings in human-readable form.
227
228 -g Print all current settings in a form that can be used as an
229 argument to another stty command to restore the current settings.
230
231 -v,--version
232 Print version info.
233
235 stty()
236 IO::Stty::stty(\*STDIN, @params);
237
238 From comments:
239
240 I'm not feeling very inspired about this. Terminal parameters are obscure
241 and boring. Basically what this will do is get the current setting,
242 take the parameters, modify the setting and write it back. Zzzz.
243 This is not especially efficent and probably not too fast. Assuming the POSIX
244 spec has been implemented properly it should mostly work.
245
246 show_me_the_crap()
247 Needs documentation
248
250 Austin Schutz <auschutz@cpan.org> (Initial version and maintenance)
251
252 Todd Rinaldo <toddr@cpan.org> (Maintenance)
253
255 This is use at your own risk software. Do anything you want with it
256 except blame me for it blowing up your machine because it's full of
257 bugs.
258
259 See above for what functions are supported. It's mostly standard POSIX
260 stuff. If any of the settings are wrong and you actually know what some
261 of these extremely arcane settings (like what 'sane' should be in POSIX
262 land) really should be, please open an RT ticket.
263
265 None
266
268 Copyright 1997 Austin Schutz, all rights reserved.
269
270 This program is free software; you can redistribute it and/or modify it
271 under the same terms as Perl itself.
272
273
274
275perl v5.36.0 2022-07-22 IO::Stty(3)