#!/bin/csh -f # # displays the volumes list and assigns a next highest # volume serial number # # written by Kevin Inscoe (kevin@inscoe.org) # # November 1, 1998 # # # define globals # @ max_label_len = 10 set preamble = "ODCOD" set dtmp = `date '+%H%M%S'` set tmp = /tmp/checkin_optical_$dtmp.tmp set log = checkin_optical.log set checkin_cmd = "/usr/lpp/adsmserv/bin/dsmlabel -library=/dev/lb0 -drive=/dev/rop0,1 -drive=/dev/rop1,2 -drive=/dev/rop2,3 -drive=/dev/rop3,4 -keep" # # ask for tapeuser password # #printf "Enter tapeuser password: " #set pa = $< top: # # Get the list of volumes, sort decending and get next volume # set lastser = `/usr/bin/dsmadmc -id=tapeuser -pa=tapeuser98 query libvol | /bin/grep $preamble | /bin/awk '{ print $2 }' | /bin/sort -n -r | /bin/head -1` #echo $lastser # # Calculate next volume # @ preamble_len = `/bin/echo $preamble | /bin/wc -m` - 1 @ cut_start_pos = $preamble_len + 1 #echo $preamble $preamble_len $cut_start_pos $max_label_len set cutparam = `/bin/printf "%i%s%i" $cut_start_pos "-" $max_label_len` #echo $cutparam set last = `/bin/echo $lastser | /bin/cut -c $cutparam` #echo $last # increment by 1 set ser = `/bin/echo $last "+1" | /usr/bin/bc` #echo $ser @ zerofill_len = $max_label_len - $preamble_len #echo $zerofill_len /bin/rm -f $tmp /bin/printf "/bin/printf \042%s%s%s\042 %s\n" "%0" $zerofill_len "d\n" $ser > $tmp /bin/chmod +x $tmp set zerofill = `exec $tmp` /bin/rm -f $tmp /bin/printf "Label the new optical cartridge with the serial number:" /bin/printf "%s%s\n" $preamble $zerofill # # label it # #echo $checkin_cmd $checkin_cmd # # Catalog and load it into ADSM and the jukebox # #/usr/bin/dsmadmc -id=tapeuser -pa=tapeuser98 checkin libvol archlib0 search=yes status=scratch /usr/bin/dsmadmc -id=archive -pa=unixrules checkin libvol archlib0 search=yes status=scratch