Managing tty Attributes in AIX
I once supported an installation with 200 to 300 tty
split between 64- and 128-port concentrators. There
were a dozen modems
and about a dozen printers of various types. Much of
the support was
performed via 9600 serial dialup lines. Using the System
Interface Tool, or SMIT (the ASCII version), to manage
attributes in this environment turned out to be highly
for these reasons:
1. There are about 50 different tty attributes
to scan through, but in my experience only two or three
are of interest,
so long as you can be sure that all the rest were set
to default values.
2. Changing/showing tty attributes in SMIT
requires plodding through a list of ttys that can number
the hundreds, then picking one of four screens for a
Guess wrong and you must start over. This can become
over low speed modem-lines.
3. When you are creating ttys, SMIT does
not allow you to specify the device name. Instead, it
next available tty number. This is a problem if you
to assign tty names consistent with port addresses.
4. It is often handy to be able to add new devices,
with attributes identical to existing devices. SMIT
does not offer
the capability to duplicate ttys, except when you are
a group of new, identical devices all at once.
Given these limitations, I developed the getattr script
It's a simple command-line tool that saves a lot
of time by filtering
out all the default settings. This script can be extended
ways. Two of those ways are shown here: the duptty script
(Listing 2), which can create a new tty with attributes
a specified existing tty, and the alltty script (Listing
which can facilitate redefinition of all ttys, printers,
modems on a system after a total reinstall of AIX. This
might generate a list of mkdev and duptty commands
to be executed after a disaster, or after a CPU upgrade
a new level of AIX (such as the model 590, which required
The getattr Script
The getattr script works with terminals, modems, or
connected on serial ports. The technique is to use the
command to compare the effective attribute values (generated
the -E flag) with the default values (generated with
flag), and report only on the non-default settings.
command redirects output into a separate temporary file.
suffix on the filenames is a Korn-shell reserved variable,
set to the PID of the current process. This serves to
The diff command does most of the work. For example,
diff to compare the two lines
term vt100 TERMINAL type (our setting, in the t1 file)
term dumb TERMINAL type (the default, in the t2 file)
would produce the following result:
< term vt100 TERMINAL type
> term dumb TERMINAL type
So, to find the lines that differ from the defaults,
pipes the diff output to an awk script, which prints
second and third blank-delimited words of every record
for which the
first word is a "<". With a little formatting
of the print
statement, and a BEGIN and END clause added, STDOUT
can be redirected to a file and executed as a chdev
However, I have used it primarily for concise reporting
to do quick comparisons between devices when trouble-shooting.
each line in the BEGIN/END construct has an escaped
to accommodate the multiple-line chdev command, I use
the END clause to add a line to the end of the output.
invocation, such as
might produce the following output:
chdev -a term=vt100 \
-a login=enable -l tty0
You can use the script with other device classes as
well. The -b
option of the diff command causes leading tabs or spaces,
as as well as strings between spaces, to be ignored
I added this option because column alignment on output
from the lsattr
command can vary, depending on values for the effective
The last line deletes the temporary files. The AIX version
systems has an alias set for rm: the command whence
outputs the command rm -i. This is handy, since the
helps root to avoid accidentally removing the wrong
files. In this
script, however, it is sensible to specify the full
pathname to rm,
so this safety feature is deactivated.
There's one other thing to remember. When the $ metacharacter
is inside single quotes, the shell does not interpret
it. These $
variables have special meaning to the awk interpreter.
The awk variables
$1, $2, etc., correspond to the first, second, etc.
word in the current input line.
The duptty Script
The duptty script (Listing 2) builds on the getattr
script. It creates a new tty with attributes identical
any specified existing tty, assigning it whatever devicename
and port address you care to specify.
Remembering the -p, -w, -t, -s, and
-c parameters is difficult. What I have often done is
SMIT to generate a command to add a device, then note
all the parameters
in the command that SMIT builds.
Each 64- or 128-port concentrator is assigned a serial
-- such as sa1, sa2, etc. -- when it is configured.
obtain these numbers from the output of the lsdev -C
The 64-port concentrators are addressed somewhat differently
the 128-port concentrators. Both boxes have 16 ports
For the 16-port concentrator, a value such as sa1 corresponds
to 1, 2, 3, or 4 concentrators connected to 4 jacks
in the adapter
installed in a particular microchannel slot, and the
will be 0-15 on the first, 16-31 on the second, 32-47
on the third,
and 48-63 on the fourth. The 128-port concentrators
assigned to separate serial adapter numbers, so the
are much more straightforward, always being 0-15, just
as they are
labeled on the concentrator.
One caveat concerning 128-port adapters: you cannot
a leading zero on the connection number for ports 0
thru 9. If you
do, an invalid connection message will result, and you
have some difficulty identifying the problem.
To delete a tty, follow this sequence of steps (substituting
the applicable number for NNN):
1. pdisable ttyNNN (this stops the getty
process on the tty)
2. chdev -l ttyNNN -a login=disable (again,
this halts the getty process)
3. rmdev -dl ttyNNN (this deletes the tty
The alltty script
I have written several throwaway scripts which execute
repeatedly, to define ttys after a reconfiguration.
if tty0 has a certain set of attributes you want to
for ttys on five 128-port concentrators, you could use
like the alltty script (Listing 3). This script will
80 ttys, on each of five concentrators, giving them
names such as tty100, tty101... tty115, tty200...tty215,
Three-digit tty numbers sort easily. The command:
lsdev -Cc tty | sort -k1
presents the ttys in numerical order only if
the ttys are defined with three digits.
This covers most of what I've learned in working with
such as ttys, printers, and modems on an RS/6000. If
any comments or other feedback, I'd like to hear from
About the Author
Steve Peterson is currently employed as an RS/6000
consultant. His current client is Aetna Life Insurance
CT, where he is helping to implement distributed AIX/DB2/DCE
on multiple RS/6000 systems. Prior to that he worked
at The Travelers for
12 years. He can be reached via email at StephenPet@Delphi.com.