#!/bin/ksh

build_query() {

echo "echo '$*' "
for i in ${_ERROR_LINE}; do
  echo " | grep $i \c"
done


}

find_known_errors() {
#set -x
cat Solaris_Errors1 | grep -v "^$" | grep -v "^#"
  while read _ERROR_LINE; do
    #echo "_ERROR_LINE = ${_ERROR_LINE}"
    first_word=$(echo ${_ERROR_LINE} | awk '{print $1}') > /dev/null
    second_word=$(echo ${_ERROR_LINE} | awk '{print $2}') > /dev/null
      if [ "${first_word}" == ".BEGIN" ]; then
         _inside_new_section=1
         #echo "Inside section ${second_word}"
      elif [ "${first_word}" == ".END" ]; then
         _exiting_new_section=1
      else
         _QUERY=$(build_query ${_MESSAGE_LINE}) > /dev/null
        ${_QUERY}
      fi
  done

}

cat messages | 
   while read _MESSAGE_LINE; do
     find_known_errors ${_MESSAGE_LINE}
   done

