shell 检查断口是否启用

来源:互联网 发布:java二叉树前序遍历 编辑:程序博客网 时间:2024/05/17 04:55
/usr/bin/nc $1 80 -w 3&>/dev/null
h=`echo $?`
if [ $h -ne 0 ]; then
        echo "error"
        exit 0
else
        echo "ping is ok!!"
fi

echo "end "



 ./pingip.sh 42.96.198.96


0 0