Hi Im trying to write a script that compare a text string.
But it fails, I think it adds a extra line feed to the result and fails beacuse of that.
The script.
DT=`date +'%Y%m%d%H%M%S'`
#ALARM_BIN=/users/alarms/ssa/alarms/bin
QUEUE_THR=10
#unset offset
#offset="***Server reports data not found"
#offset=330000
offset=`xntpdc -p |awk '{ print $7 }' |tail -1| (sed -e 's/^-//' -e 's/\.//')`
echo "$offset"
if [ "$offset" = "***Server reports data not found" ]; then
echo "Connection to NTP server lost"
${ALARM_BIN}/alarm_raise NTPCHECK ntp_check 8 8505 MAJOR "Connection to NTP server lost" SSOO
else
if (( $offset > 300000 )); then
echo "Client clock off by 0.3 seconds or more"
${ALARM_BIN}/alarm_raise NTPCHECK ntp_check 8 8507 MAJOR "Client clock off by 0.3 seconds or more" SSOO
else
echo "NTP server connection and client clock OK"
${ALARM_BIN}/alarm_raise NTPCHECK ntp_check 14 8606 CLEAR "NTP server connection and client clock OK" SSOO
fi
fi
The result is as follows
If the ntp server is available it returns a number
ntp_check
0060277
NTP server connection and client clock OK
If the ntp server is unavailable
ntp_check
***Server reports data not found
./ntp_check[16]: > 300000 : syntax error
It fails doing the comparision I dont understand why.
Why is there a blank line below
***Server reports data not found
Thanks.