#/bin/ksh # # tool to convert sd & st numbers to ctd & rmt numbers # #command line parsing for help if [[ $1 == -h || $1 == -help || $1 == \? ]] then print "USAGE: $0 [EXCLUSIVE: -tape, -disk, device-name]" print "Without an argument, does both tape and disk devices" print "NOTE: Does not do floppy or nfs devices" print "" print "$0" print "$0 -disk" print "$0 -tape" print "" print "$0 sd11" print "$0 st11" print "" exit 1 fi #command line parsing if (( ! $# )) then TYPE=both else if [[ $1 == -tape || $1 == -disk ]] then TYPE=$1 else MYDEV=$1 if [[ -n $(print $MYDEV | grep ^sd) ]] then TYPE=-disk else TYPE=-tape fi fi fi #VARS TMPFILE=/tmp/whatctd.$$ #functions disks () { if [[ -z $MYDEV ]] then DEVS=$(iostat -x | grep ^sd | awk '{print $1}') else DEVS=$MYDEV fi ls -l /dev/dsk > $TMPFILE for DEV in $DEVS do if [[ -e /opt/RICHPse/bin/se && -f /opt/RICHPse/examples/disks.se ]] then /opt/RICHPse/bin/se /opt/RICHPse/examples/disks.se | grep "$1 " else SSD_NUM=$(print $DEV | sed 's/[a-z]//g' ) SSD_NAME=$(print $DEV | sed 's/[0-9]//g' ) SSD_PATH=$(grep -w $SSD_NAME /etc/path_to_inst | \ awk '{if ($2 == '$SSD_NUM') print $1}' | sed 's/\"//g') FOUND=$(grep ../../devices${SSD_PATH} /tmp/$0.$$\ | grep ':c' \ | awk '{print $9}') print "$DEV \c" if [[ -n $SSD_PATH && -n $FOUND ]] then print "$FOUND" else print "was not found" fi fi done rm $TMPFILE } tapes () { if [[ -z $MYDEV ]] then DEVS=$(iostat -x | grep ^st | awk '{print $1}') else DEVS=$MYDEV fi ls -l /dev/rmt > $TMPFILE for DEV in $DEVS do SSD_NUM=$(print $DEV | sed 's/[a-z]//g' ) SSD_NAME=$(print $DEV | sed 's/[0-9]//g' ) SSD_PATH=$(grep -w $SSD_NAME /etc/path_to_inst | \ awk '{if ($2 == '$SSD_NUM') print $1}' | sed 's/\"//g') FOUND=$(grep ../../devices${SSD_PATH} /tmp/$0.$$ \ | grep ':$' \ | awk '{print $9}') print "$DEV \c" if [[ -n $SSD_PATH && -n $FOUND ]] then print "rmt/$FOUND" else print "was not found" fi done rm $TMPFILE } ####### # run the program ####### if [[ $TYPE == both ]] then disks tapes elif [[ $TYPE == -disk ]] then disks else [[ $TYPE == -tape ]] tapes fi