I'm getting into the error for bash shell [: : integer expression expected" while running below script.
#!/bin/bash
sm=$(ps -e | grep sendmail > /dev/null 2>&1)
pm=$(/etc/init.d/postfix status > /dev/null 2>&1)
check_mail(){
if [ "$sm" -eq 0 ]; then
echo "Service Status: Sendmail is Running!"
elif [ "$pm" -eq 0 ]; then
echo "Service Status: Postfix Service is Running!"
else
echo "Service Status: Both Sendmail & Postfix Service is Not Running On $(uname -n)"
fi
}
check_mail
While running the above script it's simply showing the output of
elsecondition.
Service Status: Both Sendmail & Postfix Service is Not Running On host
Though, i have tested "==" rather "-eq" for comparison and [[]] but did not worked.
/dev/null 2>&1giving theintegererror.