Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function not found error

Status
Not open for further replies.

Sambo8

Programmer
May 10, 2005
78
0
0
NZ
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.

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

 
Hi All,

Please ignore my above post, I found the problem was actually the if beginning above the functions with the fi below. Apologies.

Sam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top