Previous Table of Contents Next


Module 143
tset (BSD)

DESCRIPTION

The tset command sets your terminal type and stty setting when you log in to the system. It sets your erase and kill characters, sets or resets delays, and sends character sequences to initialize your terminal. This is referred to as terminal dependent initialization.

First tset determines the type of terminal being used, then performs the necessary initialization and mode settings. The type of terminal is defined in the /etc/ttytype database. Terminal types may be found as files under the /usr/lib/terminfo/[a-z] directories or as entries in the /etc/termcap database. If a port (tty) is not permanently wired to a specific terminal type (not hardwired), it will be given an appropriate generic name. For example, ports wired to modems are given a terminal type of dialup.

Some System V systems implement tset.

COMMAND FORMAT

Following is the general format of the tset command.

     tset [ -AIQShns ] [ - ] [ -ec ] [ -kc ] [ -m[ident][test/baud]:type ] \
          [ type ]

     reset

Options

The following list describes the options and their arguments that may be used to control how tset functions.

-A Asks you for the type of terminal being used.
-I Suppresses the sending of terminal initialization sequences to the terminal.
-Q Suppresses the displaying of the "Erase set to ..." and "Kill set to" messages. Quit mode.
-S Displays the terminal type that would normally be assigned to the environment variable TERM. By default tset generates a shell statement that assigns the terminal type to the variable TERM. The output from -S is often used when the login shell is sh or ksh. For example,
                         set -- `tset -S`
                          TERM=$1
sets TERM to the appropriate terminal type returned by tset.
-h Forces tset to read the /etc/ttytype file. If -h is not specified, tset reads the type from the environment variable TERM, unless mapping (-m) is specified.
-n Forces the use of the new BSD 4.x tty driver to be used on systems where it is available. If you are on a crt and the BAUD is greater than 1200, the CRTKILL and CRTERASE modes are set.
-s Generates the appropriate shell commands to set the environment variable TERM to the proper terminal type. Your SHELL variable must be set to the shell you are currently using.
- Displays the terminal type. The terminal type tset has decided upon is written on standard output.
-ec Sets the erase character (see stty) to character c. The c defaults to Ctrl-H (Backspace). You can either type c directly as a Ctrl-H or use the "hat" notation. The hat notation is "^H." The caret is the ^ character (shift 6 on your keyboard). The shell default for Backspace is #.
-ic Sets the interrupt character (see stty) to character c. The c defaults to Ctrl-C. You can set it the same way you set erase.
-kc Sets the kill character (see stty) to character c. The c defaults to Ctrl-X. If c is not specified and the kill character has not been set, then kill is set to @ (at sign).
-m[ident][test/baud]:type Maps a port identifier to a baud rate and terminal type. The -m option allows you to pass tset a set of conditions, which basically say "If I'm on this port then I'll probably be using this terminal type." Thus you "map" information into desired terminal types. The following list describes each argument of the -m option.
ident Port identification string. Identifies how a terminal is attached to each specific port on the system. Valid port identification strings are located in /etc/ttytype. If no identifier is given, all port identifiers are matched. So if you want your terminal type to always be set the same no matter what port you log in on, leave the ident field blank.
test Conditional operators used to provide a range of possible baud rates allowed for selecting the specified terminal type. The operators are,
Operator Description
> greater than
= equal to
< less than
@ equal to, at the rate of
! invert the test condition
baud Specifies the baud rate at which the computer port must be currently set for tset to select the specified terminal type. This is retrieved via stty. The tset output to set the baud rate is the stty baud command.
type Same as terminal type listed in the arguments section.

TIP:  
It is advisable to place the entire argument for each -m option in single quotes.



-n Sets the tty driver to new mode on systems with BSD 4.X tty drivers. Other mode sets include CRTERASE and CRTKILL.

If no options or arguments are specified, tset reads your terminal type from the environment and initializes the terminal.

The following options are accepted to provide compatibility with earlier versions of tset. You are discouraged from using these options since they will probably disappear in future releases of tset.

-r Displays results to user.
-Ec Same as -ec.

Arguments

The following argument may be passed to the tset command.

type Specifies the type of terminal being used. This argument overrides the type specified in /etc/ttytype. You should always use the /etc/ttytype for hardwired terminals.
If no options or arguments are specified, tset reads your terminal type from the environment and initializes the terminal.

Setting Your Shell TERM Variable

Usually, you want to set your terminal type when you log in to the system. You can do this by using tset with the -s option. In your .profile (if using the Bourne or Korn shell (sh)) type:

     eval `tset -s other_options`

The output will be

     TERM=vt100

The eval statement will execute the output as a shell command, thus setting your terminal type to vt100.

In your .login (if using the C shell (csh)) type

    set noglob; eval `tset -s other_options`; set glob

The output will be

    setenv TERM vt100

which is executed by the eval command.

Resetting Your Terminal

It is not uncommon for your terminal to be left in a strange (and often useless) state by a program that aborted for one reason or another. To reset your terminal you can use the reset command.

Since the terminal is confused, the following command may not be displayed as you type it. First type a Del character (Ctrl-C or Delete key). Type <Linefeed>reset<Linefeed>. This should reset your terminal. To check the results type a UNIX command. It should display as you type it and execute after you press Return.

The stty modes set by reset are cooked, echo, and icrnl. The cbreak and raw modes are turned off. Special control characters (erase and kill) are restored to a reasonable state. If they are unknown, then they are reset to the default values.

EXAMPLE

The following example shows you how to use tset to set the terminal type even if you log in from various ports (terminals). If you place the following command line in your .login or .profile,

     tset -Q -e"^H" -k"^X" -m 'dialup>300:vt100' -m 'dialup:adm5'\
          -m 'tty05:?tvi925'

your terminal type is set as follows:

1.  Suppress the verbose messages.
2.  Set erase character to Ctrl-H.
3.  Set kill character to Ctrl-X.
4.  If the port you log in on is a dialup with a baud rate greater than 300, the terminal type is set to vt100.
5.  If the port you log in on is a dialup with a baud rate less than or equal to 300 baud, the terminal type is set to adm5.
6.  If the port you log in on is tty05, tset prompts you for confirmation of terminal type tvi925. If you press Return, tvi925 is used as the terminal type. If you are using a different type of terminal, enter the terminal type. This new type is used by tset.
7.  If none of the conditions listed in the tset command are true, then the terminal type is set to the type defined in /etc/ttytype.

RELATED COMMANDS

Refer to the ksh and stty commands described in modules 71 and 126.

RELATED FILES

The tset command retrieves information from the following files and directories.

/etc/ttytype A database that maps port names to terminal types.
/usr/lib/terminfo/[a-z]/* The terminal type names database (SV).
/etc/termcap The terminal type database (BSD and some SV). Used instead of the new terminfo structure.

VARIABLES

The following variables are used by tset.

SHELL Used to generate the appropriate shell commands for setting the TERM variable to the correct terminal type.
TERM The name of the terminal type.

APPLICATIONS

The tset command is used to initialize your terminal, set up the correct stty modes, and provide proper shell commands for setting the terminal type. It provides a flexible way of setting your terminal type and certain control characters to desired values.

TYPICAL OPERATION

In this activity you use the tset command to display the terminal type defined for the port you are currently logged in on. Begin at the shell prompt.

1.  Type tset -h and press Return. The terminal type defined in /etc/ttytype for your port is displayed.
2.  Type tset - and press Return. This displays your current terminal type as defined in the TERM variable.
3.  Turn to Module 19 to continue the learning sequence.


Previous Table of Contents Next