Boolean expression issues

Hi everybody:

I'm working on a script to send emails with logs attached based on one single rule..."check if the number of errors has increased since the last time the script ran"

Basically what my script does is read from a previous file with the last trace of errors the previous error count, read the main log file to see if more errors has came out since the last time and compare those values. If the current count are greater than the previous one, then collect the logs and send them by email, here is the code:

#Get Previous ErrorCount variable

ERRORCOUNTPREV=`tail -1 /logs/MaxThread.log`
typeset -i ERRORCOUNTPREV
echo $ERRORCOUNTPREV >> $LOGFILE

#Set ERRORCOUNT to check_max_tomcat_threads.log for historical record

ERRORCOUNT=`grep -c maxThreads /logs/catalina.out`
echo $ERRORCOUNT >> $LOGFILE

if [["$ERRORCOUNT" > "$ERRORCOUNTPREV"]]
  then
     echo $ERRORCOUNT " errors were found on catalina.out on " $DATE " Previous error count was: " $ERRORCOUNTPREV>>$LOGFILE
     case $thehost in

                server01 )

When I run this script this throws me this output:

bash-3.00$ ./check_max_tomcat_threads_UAT.ksh 
./check_max_tomcat_threads_UAT.ksh[29]: [[6:  not found

So my concern here is that '>' is not a valid identifier for boolean expressions, or do I need to fix something else?

Any help will be highly appreciate.

Best Regards

The error is in line 29 of your script and is presumably because you need spaces between [[ and "$ERRORCOUNT" (which would be better written as "${ERRORCOUNT}" while you are at it) and also between "$ERRORCOUNTPREV" and ]].

HTH

1 Like

Begin by changing this:

[["$ERRORCOUNT" > "$ERRORCOUNTPREV"]]

to:

[[ "$ERRORCOUNT" -gt "$ERRORCOUNTPREV" ]]
1 Like

TonyFullerMalv & radoulov Thank you very much

Now it's working :smiley: