檢查可用命令

檢查可用命令

當我使用 root 使用者執行 bash 腳本時,我收到的輸出顯示 iptables 不存在。為什麼只有 root 才會出現這種情況?

for CMDAPP in "hash" "curl" "iptables"
  do

    if ! hash "$CMDAPP" 2>/dev/null
    then

        echo "`date`: $MODULE ended without '$CMDAPP' command." >> ERROR.log
        exit

    fi

  done

相關內容