Hi there,
Please can you take a look at my script, my other functions work fine but funcB gives the error: [55] funcB: not found.
Any help greatly appreciated as I haven't written functions before.
Many thanks,
Sam
Please can you take a look at my script, my other functions work fine but funcB gives the error: [55] funcB: not found.
Code:
#!/bin/ksh
CURRENTDAY=$(cat hello)
echo $CURRENTDAY
VAR=$(date +'%a')
echo $VAR
if [ $VAR = $CURRENTDAY ] ; then echo 'Matched'
#################
function funcA {
CURRENTDAY=$(cat hello)
echo $CURRENTDAY
if find /u01/app/oracle/work/sam/backup/again/errorexists.*.$CURRENTDAY -mtime -1 -print;
then exit
else funcX
fi
}
#################
function funcB {
if find /u01/app/oracle/work/sam/backup/again/errorexists.*
then
echo "OOPs might need to try at lt 1800 to wor"
else
echo "PROBLEMO"
fi
}
#################
function funcX {
CURRENTDAY=$(cat hello)
echo $CURRENTDAY
if [[ $(cksum /u01/app/oracle/work/sam/backup/again/sam.sh | nawk '{print $2}') -gt 0 ]]
then find /u01/app/oracle/work/sam/backup/again/backup.$CURRENTDAY -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
MOUNT=$(echo $FILE2 | cut -c21-23)
echo $MOUNT
[ -f errorexists.$MOUNT.$CURRENTDAY ] && touch noproblems.txt || touch errorexists.$MOUNT.$CURRENTDAY
done
else touch noerror.txt
fi
}
##################
else echo 'unMatched'
fi
HOUR=$(date +'%H')
MIN=$(date +'%M')
TIMLIO="$HOUR$MIN"
echo $TIMLIO
if [ $VAR = $CURRENTDAY ] && [ $TIMLIO -gt 1800 ] ;
then
funcA
elif [ $VAR != $CURRENTDAY ] && [ $TIMLIO -lt 1800 ] ;
then
funcB
elif [ $VAR = $CURRENTDAY ] && [ $TIMLIO -lt 1800 ] ;
then echo "probably exit now and wait till 6pm"
elif [ $VAR != $CURRENTDAY ] && [ $TIMLIO -gt 1800 ] ;
then echo "check previous days backup finished"
else echo "problems"
fi
Any help greatly appreciated as I haven't written functions before.
Many thanks,
Sam