Nishant:
This is not a valid stament/command:
Code:
STATUS1=grep -c "error_phrases" /home/psbatch/batch/error.log
You must change it to:
Code:
STATUS1=`grep -c "error_phrases" /home/psbatch/batch/error.log`
Notice that those are backticks and not apostrophies or single quotes.
or change it to:
Code:
STATUS1=$(grep -cf $SCRDIR error_phrases)
just waht you have posted above and it seems okay.
Now let me point out something here:
What is "$SCRDIR" doing in there? Is it the directory in which you have a log file to search for the patter in?
Note: "-f" option means you are specifying a file that contains the "pattern/keywords" you are searching for.
You would rather use:
Code:
grep -c error_word_of_your_interest /full/path/to/your/log/file.log
First run the above command and check its result. If it is okay then move on to this step:
Code:
COUNT=`grep -c error_word_of_your_interest /full/path/to/your/log/file.log`
or
Code:
COUNT=$(grep -c error_word_of_your_interest /full/path/to/your/log/file.log)
echo "Number of Errors Found: " $COUNT
Please let us know if the above solution does not work for you. Post your exact script hre.