#/bin/ksh # # tool to convert ctd & rmt numbers to sd & st 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 c0t0d0 (it assumes s2)" print "$0 22 (it assumes rmt/)" 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 ^c) ]] then TYPE=-disk else TYPE=-tape fi fi fi #functions disks () { if [[ -z $MYDEV ]] then DEVS=$(ls -l /dev/dsk/c*t*d*s2 | awk '{print $9}') else if [[ -z $(print $MYDEV | grep s2$) ]] then DEVS=/dev/dsk/${MYDEV}s2 else DEVS=/dev/dsk/$MYDEV fi fi for DEV in $DEVS do print "$DEV \c" if [[ -L $DEV ]] then ITEM=$(ls -l $DEV | \ awk '{print $11}' | \ cut -c14- | \ awk -F: '{print $1}') grep $ITEM /etc/path_to_inst | awk '{printf "sd%d \n", $2}' else print "was not found" fi done } tapes () { if [[ -z $MYDEV ]] then DEVS=$(ls -l /dev/rmt/*[0-9] 2> /dev/null | awk '{print $9}') else DEVS=/dev/rmt/$MYDEV fi for DEV in $DEVS do print "$DEV \c" if [[ -L $DEV ]] then ITEM=$(ls -l $DEV | \ awk '{print $11}' | \ cut -c14- | \ awk -F: '{print $1}') grep $ITEM /etc/path_to_inst | awk '{printf "st%d \n", $2}' else print "was not found" fi done } ####### # run the program ####### if [[ $TYPE == both ]] then disks tapes elif [[ $TYPE == -disk ]] then disks else [[ $TYPE == -tape ]] tapes fi