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
 
getusershell(3C)					   Standard C Library Functions 					  getusershell(3C)

NAME
getusershell, setusershell, endusershell - get legal user shells SYNOPSIS
#include <unistd.h> char *getusershell(void); void setusershell(void); void endusershell(void); DESCRIPTION
The getusershell() function returns a pointer to a legal user shell as defined by the system manager in the file /etc/shells. If /etc/shells does not exist, the following locations of the standard system shells are used in its place: /bin/bash /bin/csh /bin/jsh /bin/ksh /bin/ksh93 /bin/pfcsh /bin/pfksh /bin/pfsh /bin/sh /bin/tcsh /bin/zsh /sbin/jsh /sbin/pfsh /sbin/sh /usr/bin/bash /usr/bin/csh /usr/bin/jsh /usr/bin/ksh /usr/bin/ksh93 /usr/bin/pfcsh /usr/bin/pfksh /usr/bin/pfsh /usr/bin/sh /usr/bin/tcsh /usr/bin/zsh /usr/sfw/bin/zsh /usr/xpg4/bin/sh The getusershell() function opens the file /etc/shells, if it exists, and returns the next entry in the list of shells. The setusershell() function rewinds the file or the list. The endusershell() function closes the file, frees any memory used by getusershell() and setusershell(), and rewinds the file /etc/shells. RETURN VALUES
The getusershell() function returns a null pointer on EOF. BUGS
All information is contained in memory that may be freed with a call to endusershell(), so it must be copied if it is to be saved. NOTES
Restricted shells should not be listed in /etc/shells. SunOS 5.11 1 Nov 2007 getusershell(3C)
All times are GMT -4. The time now is 01:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy