Hi there,
The following is my script:
I get the following errors when I run the script as a whole:
./backupchk.sh[27]: test: ] missing
./backupchk.sh[32]: /u01/app/oracle/work/sam/backup/errorexists.u01.Wed: cannot execute
./backupchk.sh[38]: Error: not found
however if I run the script in sections each section seems to be working. Any help aprreciated.
Sam
The following is my script:
Code:
#/usr/bin/ksh
# this gets yesterdays day
SAM=$(TZ=CST+24 date '+%a')
echo $SAM
ERROR1=$(echo "Email backup not run PLEASE CHECK")
ERROR2=$(echo "Error in backup see backuperrordetails.log for details")
find /u01/app/oracle/work/sam/backup/backup.$SAM -mtime -1 -print > output
#
if [[ $(cksum /u01/app/oracle/work/sam/backup/output | nawk '{print $2}') -gt 0 ]]
then echo "the file exist" > blah.txt
else echo "file doesn't exist send mail to say no backup" $ERROR1
fi
if [[ $(cksum /u01/app/oracle/work/sam/backup/blah.txt | nawk '{print $2}') -gt 0 ]]
then echo "gotta tail that file and send error" > problems.txt
else > problems.txt
fi
#
echo $SAM
if [[ $(cksum /u01/app/oracle/work/sam/backup/problems.txt | nawk '{print $2}') -gt 0 ]]
then find /u01/app/oracle/work/sam/backup/backup.$SAM -mtime -1 -print | xargs grep Error | while read LINE
do
FILE2=$(echo $LINE | sed 's/.* see //;s/ for details//')
echo $FILE2
[[ -f "$FILE2" ]] && tail -5 $FILE2 || echo "($FILE2 not found)"
echo $FILE2
VAR=$(echo $FILE2 | cut -c2-4)
echo $VAR
[ -f errorexists.$VAR.$SAM ] $$ "no error" > noproblems.txt || touch errorexists.$VAR.$SAM
done
else touch noerror.txt
fi
#
if /u01/app/oracle/work/sam/backup/errorexists.$VAR.$SAM -newer timelastrun.txt > /dev/null
then tail -5 $FILE2 > backerrordetails.log
else touch nada.txt
fi
#
if [[ $(cksum /u01/app/oracle/work/sam/backup/backerrordetails.log | nawk '{print $2}') -gt 0 ]]
then $ERROR2
else touch nada.txt
fi
#
touch timelastrun.txt
I get the following errors when I run the script as a whole:
./backupchk.sh[27]: test: ] missing
./backupchk.sh[32]: /u01/app/oracle/work/sam/backup/errorexists.u01.Wed: cannot execute
./backupchk.sh[38]: Error: not found
however if I run the script in sections each section seems to be working. Any help aprreciated.
Sam