Basics,Linux,Linux,MacOSX,MacOSX,Terminals,Unix

2013/08/15

Both of these have to do with your terminal. Either can be informational (telling you something about
your terminal settings) or active (changing something). For example, "tput" can control the position of
the screen cursor:

Try this:

You can look up the things you can do in
"man terminfo". For example, "tput clear" will clear the screen,
while "tput cols" will tell you how wide your terminal is.

Another useful resource is Colours and Cursor Movement With tput.

On the other hand, stty controls things like "echo". Let's say that you wanted
to turn off character echo while reading a password. You could do this:

Why save the old stty settings? It's so you can put them back to what they were. If you just
said "stty echo". you are assuming that's how it was previously set. It might not be: if the script
was called from an emacs session, echo would have been off and you would have turned it back on!

You can set colors: Using color in shell scripts (Linux, Mac OS X),
switch to a line drawing characer set and much more.

A simple "stty sane" can often restore a garbled screen (see My screen is completely unreadable if that's not enough).

You might also try "tput reset" and "tput init" (which may be indentica;l see "man tput").

You can fix backspace confusion that comes up when telneting from Linux to SCO:

(From Problem with backspace key when telnet from Linux)

A common confusion for folks unfamiliar with SCO is that, by default, SCO systems set interrupt to the DELETE
key, not CTRL-C. If you find that unbearable, you can easily change
it; for example,

will change your interrupt on Bourne or Korn shells. In this
example, you actually type CTRL-C; if you are in vi adding it to
your .profile, type CTRL-V and then CTRL-C

This can also be added to .profile (or whatever startup file your
shell uses) or to /etc/profile.

We'd use stty "hold-open" scripts to control settings on serial printers also.

Flow control is also controlled by stty. That's often needed for serial sevices, but even on virtual terminals you can pause output with Cntrl-S and (if stty ixany is set), restart it with any keystroke.

Should you happen to be using a serial terminal for some reason, Linux Serial How-To may be helpful. Real serail terminal or not, "stty -a" will display its settings:

The 9600 baud is meaningless unless you really are on serial.

Serial Wiring and Communications for the Confused might also be useful if you find yourself dealing with some ancient serial system.

See also Terminfo Capabilities and Termcap and Terminfo.

Comments: Click Here.

Want to showcase your product to our audience? Check our advertising options.

Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them.

I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you
to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. If you have any question, please do feel free to contact me.

-

Samepage - Redefining how people create and share information

-

Kerio Mail Server, Firewall and more



Show more