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
 
DH-EXEC-INSTALL(1)						      dh-exec							DH-EXEC-INSTALL(1)

NAME
dh-exec-install - Install (and possibly rename) files. SYNOPSIS
#! /usr/bin/dh-exec debian/default.conf => /etc/my-package/start.conf usr/bin/* DESCRIPTION
Being a sub-command of dh-exec(1), this program must not be ran directly, but through dh-exec, which automatically runs all available sub-commands if run bare; or explicitly with dh-exec --with=install. It is meant to be used for dh_install(1) files, and those alone. If it finds that its input is not such a file, it will do nothing, but echo back the contents. The purpose of the program is to extend dh_install(1)'s functionality, by allowing to specify a destination filename. This can be accomplished by a special syntax: the " => " mark between a source and a destination means that the source file should be installed with the specified destination name. For obvious reasons, the source must not be a wildcard, and the destination in this case must be a file, and not a directory. All other non-comment lines are left alone. RESTRICTIONS
Due to the way executable scripts are called from debhelper(1), there is no way to know what options were used for the original dh_install(1). This means, that the --sourcedir option of dh_install(1) will not work correctly when dh-exec-install is in use. IMPLEMENTATION
Internally, the renaming happens by creating a temporary directory under debian/tmp/, and copying (or moving, if the source was under debian/tmp/ to begin with) the file there, with the new name. This is done this way to allow dh_install(1) to do the real copying, and allow its options to continue working, even when renaming is involved. The temporary directory is put under debian/tmp so that it will be cleaned by dh_prep(1) when the clean target gets to run. Thus, no extra code is needed anywhere to clean up the renamed files. ENVIRONMENT
DH_EXEC_SCRIPTDIR Indicates which directory the command-specific scripts should be sought for. If not specified, scripts will be searched for in /usr/share/dh-exec/. FILES
$DH_EXEC_SCRIPTDIR/dh-exec-install-* The various scripts for the higher-level program. SEE ALSO
debhelper(1), dh-exec(1), dh_install(1) AUTHOR
dh-exec-install is copyright (C) 2011-2012 by Gergely Nagy <algernon@madhouse-project.org>. 2012-05-03 DH-EXEC-INSTALL(1)
All times are GMT -4. The time now is 11:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy