NEED HELP SAVING THE TTY & LP DEFINITIONS
ITEM: RTA000042906
QUESTION:
My customer is upgrading several 7012-320s running AIX 3.1.5 from
8-port RS232 to 16-port RS232 configurations. The 8-port cards have
ASCII terminals and printers defined. What are the procedures to save
the current tty and lp definitions, so these definitions can be
restored on the new 16-port card configurations? The 8-port cards
will not co-exist with the 16-port card configurations. What would
the procedure be if the RS/6000s were 7011-220s running AIX 3.2.3 Ext.?
---------- ---------- ---------- --------- ---------- ----------
A: The safest way would be to write down the configurations, remove
the configurations, replace the adapter and read the configurations.
With a little more time on research, I will provide a tested step
by step procedure.
---------- ---------- ---------- --------- ---------- ----------
A: After several days writing shell scripts to accomplish this -
we have it finished. These shell scripts when used in the
correct order, explained below, will save all information about
the 8-Port Asynchronous Adapter and put them in files. These
files will be named after the tty# and the lp# in files called:
tty#.info lp#.info lp#.out
Also, there will be two other files created which contain the
lp devices and tty devices and their corresponding ports. These
files are named:
tty_ports lp_ports
There are five shell scripts. Two of which you need to concern
yourself with on the command line:
save_and_remove restore_config
Here are the steps you need to follow:
1. Get root on the machine.
2. Type in the shell scripts. Make sure they are typed in
correctly. Be careful about the brackets, single
quotes, back ticks, etc...
3. Make the shell scripts executable. You can do this by
using the command:
chmod 777
4. After all this is verified, you are ready to remove the
information from the machine, including the adapter
definition. To do this, type:
save_and_remove
NOTE: You will see messages one at a time as things
progress. Users will be logged off and the
tty's removed. Printers will be removed.
5. Shutdown your system. To do this, type:
shutdown -F
NOTE: This is a fast shutdown. There is no time
delay between when the command is run and the
system is being shut down.
6. Remove the 8-Port Adapter card and replace it in the
same slot by the 16-port adapter. Make sure the card
is seated correctly.
7. Power on the RISC. Wait until you get a login. Log in
as root - again.
8. Now, you can run the command to restore all the
information. This command is:
restore_config
9. Again, you will be notified as each action takes place.
You should see your terminals pop back to "life." Your
printers will be restored. All in the same port number
as your 8-Port Adapter.
10. You are done¢ Not too hard¢
Now, for the rest of my answer, I will give you the shell scripts.
Each program will be separated by a line of equals (=======). I
will also give you the name of the program in the second line of
code (#save_and_remove). IMPORTANT: The first line MUST be:
#¢/bin/ksh
if it is listed this way. Not all of the shell scripts have this.
I will give you a listing of all the character translations in
case this does not go over HONE correctly:
| = pipe ` = back tick (above the tilde)
' = single quote { = open curly brace
} = close curly brace . = open bracket
. = close bracket $ = dollar sign
\ = back slash / = fore slash
# = pound sign > = greater than
< = less than = = equals
_ = underscore
Also, if you have any problems with the scripts running, then take
the lines that end in '\' and join them with the line below them
to make one continuous line. I had to break the long lines up to
fit them in HONE. However, they should work as is.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-=-= DISCLAIMER: =-=-
=-=- -=-=
-=-= These shell scripts have been tested on our test machines =-=-
=-=- successfully with AIX 3.2.5. We started out with an -=-=
-=-= 8-Port adapter in slot 4. Then, we replaced the adapter =-=-
=-=- with a 16-port adapter in slot 4, again. Everything -=-=
-=-= worked correctly with this setup. We do not guarantee =-=-
=-=- these scripts to work on every machine and every -=-=
-=-= configuration. However, we tried to make the scripts as =-=-
=-=- portable as possible. -=-=
-=-= =-=-
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
====================================================================
#¢/bin/ksh
#NAME: save_and_remove
# This script saves the definitions for ttys and lps, then removes the
# parent 8-Port adapter
slot=`lsdev -C | grep "8-Port Asynchronous Adapter EIA-232" \
| awk '{print $3}'`
# find the slot where the parent adapter resides
parent=`lsdev -C | grep "8-Port Asynchronous Adapter EIA-232" \
| awk '{print $1}'`
lsdev -Cc tty | sort | grep $slot \
| awk '{sub(/.0-9.+-.0-9.+-.0-9.+-0/,"")
print $1 " " $3}' > tty_ports
# save only the ttys on the parent adapter
lsdev -Cc printer | sort | grep 00-04 \
| awk '{sub(/.0-9.+-.0-9.+-.0-9.+-0/,"")
print $1 " " $3}' > lp_ports
# save only the lps on the parent adapter
for tty_loop in `cat tty_ports | awk '{print $1'}`
do
save_config $tty_loop # save tty config
pdisable $tty_loop # disable terminals
rmdev -l $tty_loop -d # remove the tty
done
# process each tty
for lp_loop in `cat lp_ports | awk '{print $1'}`
do
save_config $lp_loop # save lp config
odmget -q "name like $lp_loop" CuDv > $lp_loop.out
rmdev -l $lp_loop -d # remove the lp
done
#process each lp
rmdev -l $parent -d # remove the parent adapter
diag -a # and ensure that it is removed
# from the ODM
echo "The system is ready to be powered down."
echo "Swap the adapter cards then reboot."
====================================================================
#NAME: save_config
lsattr -F 'attribute value' -l $1 | awk '{print "-a" $1 "=" $2}' \
| awk '{sub("`","\\`");print $0}' > $1.info
====================================================================
#¢/bin/ksh
#NAME: restore_tty_config
CLASS=tty
TTYTYPE=tty
TTYINT=rs232
PARENT=$1
PORT=$2
FILE=$3
mkdev -c $CLASS -t $TTYTYPE -s $TTYINT -p $PARENT -w $PORT -f $FILE
====================================================================
#¢/bin/ksh
#NAME: restore_lp_config
CLASS=printer
FILE=$3
NAME=`basename $FILE .info`.out
TTYTYPE=`cat $NAME | grep PdDvLn | cut -d/ -f3 | cut -d'"' -f1`
TTYINT=rs232
PARENT=$1
PORT=$2
mkdev -c $CLASS -t $TTYTYPE -s $TTYINT -p $PARENT -w $PORT -f $FILE
====================================================================
#¢/bin/ksh
#NAME: restore_config
# This script rebuilds the tty and lp definitions for the
# 16-Port Adapter
parent=`lsdev -C | grep "16-Port Asynchronous Adapter EIA-232" \
| awk '{print $1}'`
# find the parent where the parent adapter resides
# restore_tty_config parameters: parent, port, file
exec 3
WWQA: ITEM: RTA000042906 ITEM: RTA000042906
Dated: 06/1996 Category: RISCADEV
This HTML file was generated 99/06/24~12:43:17
Comments or suggestions?
Contact us