I need to find out and trigger if the service is running to OK and not running to NOTOK. I use the below script but, its not the precise output. Anything missed out in the script:
if chkconfig --list | grep -i sendmail
then
echo " The sendmail service is not running : STATUS--> NOOK"
echo
else
echo " The sendmail service is running : STATUS--> OK"
echo
fi
Actually, if the sendmail if on -> its should flag as OK
and if sendmail if off -> it should flag as NOTOK as per the command chkconfiig -list | grep -i sendmail
chkconfig --list | grep -i sendmail
sendmail 0: off 1: off 2: on 3: on 4 :on 5: on 6: off
I got the error while using the script like below:
if chkconfig --list telnet | grep -w 'on'
then echo " telnet configured for autostart : STATUS--> NOOK"
echo
else
echo " telnet not configured for autostart : STATUS--> OK"
echo
fi
ERROR : error reading information on service telnet: No such file or directoryEven I tried with the below script: no luck.
if chkconfig --list | grep -i telnet | grep -w 'on'
then
echo "telnet is disabled: STATUS--> OK"
echo
else
echo "telnet is enabled: STATUS--> NOTOK"
echo
fi
echo
My last post was mistaken; indeed there must be chkconfig --list | grep
if chkconfig --list | grep 'telnet.*[[:blank:]]on'
then
echo " telnet configured for autostart : STATUS--> NOOK"
echo
else
echo " telnet not configured for autostart : STATUS--> OK"
echo
fi