zoukankan      html  css  js  c++  java
  • shell脚本检查网段内的ip是否可以被ping通

    while版本

    #!/bin/bash
    i=1
    while [ $I -le 254 ]
    do
      ping -c2 -i0.3 -W1 172.24.132.$i &>/dev/null
      if [ $? -eq 0 ]; then
        echo "172.24.132.$i is up"
      else
        echo "172.24.132.$i is down"
      fi
      let i++
    done

    for版本

    #!/bin/bash
    for i in {1..254}
    do
      ping -c2 -i0.3 -W1 172.24.132.$i &>/dev/null
      if [ $? -eq 0 ]; then
        echo "172.24.132.$i is up"
      else
        echo "172.24.132.$i is down"
      fi
    done

    多进程版本

    #!/bin/bash
    testping(){
    ping -c2 -i0.3 -W1 $1 $>/dev/null
    if [ $? -eq 0 ]; then
    echo "$1 is up"
    else
    echo "$1 is down"
    fi
    }
    
    for i in {1..254}
    do
      testping 172.24.132.$i &
    done
  • 相关阅读:
    Multidimensional Arrays
    TortoiseGit
    Excel教程(14)
    Excel教程(13)
    Excel教程(12)
    Excel教程(11)
    lock
    reflect
    game
    html x
  • 原文地址:https://www.cnblogs.com/laiyuan/p/10044047.html
Copyright © 2011-2022 走看看