[Networker] Shared Scripts?
2010-09-08 08:29:16
#*** Disclaimer, this script for example only edit/use at your own risk.
#*** I am not the best script writer in the world, but this is my
contribution to the list...
#*** Could you share your best scripts with the list as well?
#!/bin/ksh
# Label all recyclable IncrementalLike tapes in a jukebox
if [ "$1" = "-?" ] ;then
echo ""
echo "`basename $0` labels all recyclable IncrementalLike tapes in a
jukebox"
echo ""
echo "Usage: `basename $0` [jukebox]"
echo "Example: `basename $0` lvt_sl8500"
echo ""
exit 1
fi
NSRJBFIL=/tmp/`basename $0`.nsrjb
if [ $# -gt 0 ] ;then
JBNAME=$1
JBNAMESC=`echo $JBNAME | sed 's!:!\\\:!g'` ;# Jukebox name with
":" escaped
nsrjb -j $JBNAME -Cv > $NSRJBFIL
else
JBNAME=""
nsrjb -Cv > $NSRJBFIL
fi
SLIST=""
SCOUNT=0
for S in `grep " IncrementalLike .*yes" $NSRJBFIL | awk '{print $1}' |
tr -d ':'`
do
SLIST="$SLIST $S"
(( SCOUNT += 1 ))
done
if [ $SCOUNT = 0 ] ;then
echo "No recyclable tapes in jukebox."
exit 0
else
echo "About to label $SCOUNT tapes. ENTER to continue: \c"
read IT
fi
# Label tapes in groups of 10 so we don't exceed command line
limitations
SL="" ;# Short list
SCT=0 ;# Short list count
for S in $SLIST
do
# For each tape in the main list
SL="$SL -S $S" ;# Add to short list
(( SCT += 1)) ;# Increment short list count
if [ $SCT -ge 10 ] ;then
# We have 10 slots to label. Label them now.
if [ -z $JBNAME ] ;then
# No need to specify which jukebox
nsrjb -Lv -b IncrementalLike -R $SL ;# Label tapes in 10
slots
else
nsrjb -j $JBNAME -Lv -b IncrementalLike -R $SL
fi
SCT=0 ;# Zero out short list count
SL="" ;# And the short list itself
fi
done
if [ $SCT -gt 0 ] ;then
# There are leftover slots. Label those tapes too.
if [ -z $JBNAME ] ;then
nsrjb -Lv -b IncrementalLike -R $SL ;# Label the rest of the
tapes
else
nsrjb -j $JBNAME -Lv -b IncrementalLike -R $SL
fi
fi
#Semper fidelis, /ALE
To sign off this list, send email to listserv AT listserv.temple DOT edu and
type "signoff networker" in the body of the email. Please write to
networker-request AT listserv.temple DOT edu if you have any problems with this
list. You can access the archives at
http://listserv.temple.edu/archives/networker.html or
via RSS at http://listserv.temple.edu/cgi-bin/wa?RSS&L=NETWORKER
|
|
|