Sponsored Content
Full Discussion: Hi all
Top Forums Shell Programming and Scripting Hi all Post 302269696 by ma466 on Thursday 18th of December 2008 09:55:22 AM
Old 12-18-2008
Hi all

I have run the following program but i am getting the error: The programs is below

Code:
#!/usr/bin/ksh

# This script injects tapes from the inport 
# If the argument -c is passed it runs until CRTL-C is pressed.
# It logs in a logfile of the type /tmp/tldtest.<YYYYMMDD>

DATE=`date +'%D %X'`
logdate=`date +'%Y%m%d'`
echo "" >> /tmp/tldtest.$logdate
echo "$DATE TAPE INJECT STARTED" >> /tmp/tldtest.$logdate
count=0
while [ "$1" = "-c" -o $count -lt 1 ]
do
TRY=1
ERRORCODE=1
while [ $ERRORCODE -gt 0 -a $TRY -lt 4 ]
do
# check if there are any empty slots in the robot according to netbackup
/usr/openv/volmgr/bin/vmcheckxxx -rt tld -r 0 -rh sapbck1 | grep empty | cut -c 14- > /tmp/emptyslots 2>&1
ERRORCODE=$?
if [ $ERRORCODE -ne 0 ]; then
sleep 10
let TRY=${TRY}+1
fi
done

if [ ! -s /tmp/emptyslots ]; then
echo "NO EMPTY SLOTS"
exit 0
fi
EMPTY="yes"
while [ "$EMPTY" != "no" ]
do
# examine the inport
echo "s i" | /usr/openv/volmgr/bin/tldtest -r /dev/sg/c2t0l0 | tail +3 > /tmp/inport 2>&1
SOURCE=`grep Source /tmp/inport`
if [ -n "$SOURCE" ];then
  echo "Ejected tapes in inport" >> /tmp/tldtest.$logdate
  echo "TAPE INJECT COMPLETED" >> /tmp/tldtest.$logdate
  exit 0
fi

# check if the inport slots are full and find the connection between inport slot and mediaid
/bin/rm -f /tmp/mediainport
nr=1
cat /tmp/inport |
while read line
do
read line2 line3
fullyes=`/bin/echo "$line $line2 $line3" | grep full | sed 's/^.*full...//'`
if [ "$fullyes" = "1" ]; then
  read var1 var2 mediaid
  echo "port$nr $mediaid" >> /tmp/mediainport
  EMPTY="no"
fi
let nr=${nr}+1
done

# clean up and exit if the inport is empty 
if [ ! -e /tmp/mediainport ]; then
if [ "$1" = "-c" ]; then
sleep 120
else
/bin/rm -f /tmp/emptyslots /tmp/inport /tmp/mediainport
exit 0
fi
fi
done
# move media in inport to the empty slots
nr=1
tail -4 /tmp/emptyslots |
while read var slot line
do
cat /tmp/mediainport | grep "port$nr" | read port mediaid

# if inport slot nr contains media move it and update netbackup volume database
if [ -n "$mediaid" ]; then
echo "TAPE: $mediaid" >> /tmp/tldtest.$logdate
echo "m i$nr s$slot" | /usr/openv/volmgr/bin/tldtest -r /dev/sg/c2t0l0 >> /tmp/tldtest.$logdate 2>&1
/usr/openv/volmgr/bin/vmquery -m $mediaid 1> /dev/null 2>&1
 if [ $? -eq 35 ] ; then 
   /usr/openv/volmgr/bin/vmadd -m $mediaid -mt dlt 
   /usr/openv/volmgr/bin/vmchange -res -m $mediaid -b $mediaid -mt dlt -rt tld -rn 0 -rc1 $slot -rh sapbck1
   /usr/openv/volmgr/bin/vmchange -m $mediaid -p 5
 else
   /usr/openv/volmgr/bin/vmchange -res -m $mediaid -b $mediaid -mt dlt -rt tld -rn 0 -rc1 $slot -rh sapbck1 
   /usr/openv/volmgr/bin/vmchange -m $mediaid -p 5 >> /tmp/tldtest.$logdate 2>&1
 fi
fi
let nr=${nr}+1
done
let count=${count}+1
done
# general clean up
/bin/rm -f /tmp/emptyslots /tmp/inport /tmp/mediainport /tmp/tapesinrobot
echo "TAPE INJECT COMPLETED" >> /tmp/tldtest.$logdate
echo "" >> /tmp/tldtest.$logdate
# ./robot.ksh

./robot.ksh: line 16: [: TRY: integer expression expected
tail: cannot open input
#


Last edited by zaxxon; 12-18-2008 at 11:02 AM.. Reason: Added code tags
 
rmvb(9F)						   Kernel Functions for Drivers 						  rmvb(9F)

NAME
rmvb - remove a message block from a message SYNOPSIS
#include <sys/stream.h> mblk_t *rmvb(mblk_t *mp, mblk_t *bp); INTERFACE LEVEL
Architecture independent level 1 (DDI/DKI). PARAMETERS
mp Message from which a block is to be removed. mblk_t is an instance of the msgb(9S) structure. bp Message block to be removed. DESCRIPTION
rmvb() removes a message block (bp) from a message (mp), and returns a pointer to the altered message. The message block is not freed, merely removed from the message. It is the module or driver's responsibility to free the message block. RETURN VALUES
If successful, a pointer to the message (minus the removed block) is returned. The pointer is NULL if bp was the only block of the message before rmvb() was called. If the designated message block (bp) does not exist, -1 is returned. CONTEXT
rmvb() can be called from user or interrupt context. EXAMPLES
This routine removes all zero-length M_DATA message blocks from the given message. For each message block in the message, save the next message block (line 10). If the current message block is of type M_DATA and has no data in its buffer (line 11), then remove it from the message (line 12) and free it (line 13). In either case, continue with the next message block in the message (line 16). 1 void 2 xxclean(mp) 3 mblk_t *mp; 4 { 5 mblk_t *tmp; 6 mblk_t *nmp; 7 8 tmp = mp; 9 while (tmp) { 10 nmp = tmp->b_cont; 11 if ((tmp->b_datap->db_type == M_DATA) && (tmp->b_rptr == tmp->b_wptr)) { 12 (void) rmvb(mp, tmp); 13 freeb(tmp); 14 } 15 tmp = nmp; 16 } 17 } SEE ALSO
freeb(9F), msgb(9S) Writing Device Drivers STREAMS Programming Guide SunOS 5.10 11 Apr 1991 rmvb(9F)
All times are GMT -4. The time now is 07:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy