我进入了错误的bash shell [: : integer expression expected"
以下运行脚本时击错误[:整数表达式预期”
#!/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
在运行上面的脚本它只是显示的
else
输出。条件。
Service Status: Both Sendmail & Postfix Service is Not Running On host
虽然,我已经测试 “==”,而 “当量”作为比较和[[]]
但没有奏效。
你的所有输出发送到devnull,所以会有没有在你的增值经销商。 – 123
@ 123,即使没有将输出重定向到发生'integer'错误的'/ dev/null 2>&1'。 – krock1516
因为这些命令都不输出整数。 – 123