ps:需要在同一目录底下新建一个1.txt的文件然后执行sh ping.sh 1.txt即可

    1. #!/bin/bash
    2. . /etc/init.d/functions
    3. for ip in `cat 1.txt`
    4. do
    5. echo "Test $ip if is alive"
    6. ping $ip -c1 &>/dev/null
    7. if [ $? -gt 0 ];then
    8. echo "$ip ping不通!!!!"
    9. continue
    10. else
    11. echo "ok"
    12. fi
    13. done