我進入了錯誤的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