I am having some problem cutting and comparing values.I got an INI file which is has some values and ranges mapping to error and warning codes
eg
criticalerror:69,20,1to9
warningmsg:101,10to19
So taking the scenrio where i have a control script that execute a.ksh, when a.ksh returns a value , in this case 8, i need to map the return code to the critical error that is within the range 1 to 9.
And i have having a tough time trying to cut using expr or awk toactually retrive the 1 to 9 and using it to compare. My approach is to do something and retrive 1 and 9 and use it to compare the return code.however i am having rather diffculty cutting and comparing.
# !/usr/bin/ksh
mesg=""
first=0
last=0
notfound=1
while read line
do
mesg=`echo $line | sed 's/:.*//'`
echo $line | sed -e 's/^.*://;s/\(.*\),\(.*\),\(.*\)to\(.*\)/\3 \4/' | read first last
if [ \( $1 -ge $first \) -a \( $1 -le $last \) ]
then
echo "message is $mesg"
notfound=0
fi
done < ini
if [ $notfound -eq 1 ]
then
echo "unable to find message"
fi
exit 0
>cat ini
criticalerror:69,20,1to9
warningmsg:101,1,10to19