Hey all, I need some assistance. I'm writing a script to eject tapes from a tape library, but the library is not a queued system and can only eject 15 tapes at a time.
I added paste -d : -s so that it goes through full_tapes and puts each media_id on one line separated by the :.
Now I'm stuck on how to I separate each set of 15 into multiple lines, if I have over 15 tapes. Otherwise, this works great if I only have to eject 15 tapes.
Here is what I have so far.
#!/usr/bin/ksh
#################################
# DEFINE FILES & VARIABLES HERE #
#################################
TAPE="/usr/openv/netbackup/bin/lto-fullt.mail"
FULL_TAPES"/usr/openv/netbackup/bin/full_tapes"
#####################
# BEGINNING OF MAIN #
#####################
for i in "${TAPE}"
do
cat $TAPE |awk '{ print $1 }' | paste -d : -s > full_tapes
done
for j in "${FULL_TAPES}"
do
/usr/openv/volmgr/bin/vmchange -res -multi_eject -w -verbose -rn 0 -rt TLD -rh bkup2 ml $FULL_TAPES
if [ "j" -eq 0 ] ; then
echo "$FULL_TAPES Ejected successfully "
else
echo "$FULL_TAPES Eject failed"
fi
else
echo "$FULL_TAPES not in library "
fi
fi
done
The full_tapes media_id looks like.
L012345
L045583
L012314
L098008
L043243
L076865
L099002
L000883
L032329
L045768
L034567
L012908
L056742
L090723
L000012
L090972
L001221
L001102
L007881
L001229
L000912
L000898
After paste -d : -s
L012345:L045583:L012314:L098008:L043243:L076865:L099002:L000883:L032329:L045768:
L034567:L012908:L056742:L090723:L000012:L090972:L001221:L001102:L007881:L001229:
L000912:L003452:L001222:L000081:L000082:L000181:L000002:L000454:L000456:L000459:
L000239:L000231:L000991:L000993:L000349:L000003:L000023:L000087:L001220:L003344