检查一个范围内ip存活

#!/bin/bash
i=0
      for var in {1..254}
        do
           ping -c 2 192.168.1.$var >/dev/null 2>&1
           status=$?
        if [ $status = 0 ];then
           echo "ping 192.168.1.$var is up" >>up.txt
        else
            echo "ping 192.168.1.$var is down" >>down.txt
        fi
done

作者: 非洲乌龟   发布时间: 2010-12-02