Cover V10, I02
Article
Listing 1

feb2001.tar


Listing 1

#!/usr/bin/ksh
###############################################################################
#
# AUTHOR Todd A. Fiedler
#
# CREATED 7 SEP 2000
#
# PURPOSE
#
# This script prints a table that shows the relationship between instance
# names, logical names, and physical device paths.
#
# The logical device reported is the slice 2 although it would probably be
# more appropriate to remove the slice from the logical name and present only
# a disk.
#
###############################################################################
#
# give me a list of all devices in the /dev/dsk directory in format
# logical_name=path_to_inst and store it in the array DISKLIST
#

set -A DISKLIST $(ls -l /dev/dsk | grep c[0-9]*t[0-9]*d[0-9]*s2 | \
 awk '{printf "%s:%s\n",$9,$11}' | sed -e "s/..\/..\/devices//g")

#
# map the logical device to the physical instance name
#
typeset -i C1=10
typeset -i C2=16
typeset -i C3=52

print "\nDevice Map for $(uname -n)\n"

printf "\t%-${C1}s%-${C2}s%-${C3}s\n\n" \
 "Instance" \
 "Logical Name" \
 "Physical Path"

while [ $i -lt ${#DISKLIST[*]} ]; do

typeset -i i=0
 PHYSICAL=$(print ${DISKLIST[$i]} | awk -F':' '{print $2}')
 LOGICAL=$(print ${DISKLIST[$i]} | awk -F':' '{print $1}')
 INSTANCE=$(grep $PHYSICAL /etc/path_to_inst | sed -e "s/\"//g" | \
  awk '{printf "%s%s\n",$3,$2}')

 printf "\t%-${C1}s%-${C2}s%-${C3}s\n" $INSTANCE $LOGICAL $PHYSICAL

 ((i=(i+1)))
done

printf "\n"

###############################################################################

#
# End of script
#
###############################################################################