ping主机在线统计脚本
//ping测试检测局域网在线主机与不在线主机,并分别将它们打印出来//并统计它们的数量#!/bin/bash#
//声明网络地址host_pre="192.168.0"
//声明在线主机数量declare -i active_sum=0//声明不在线主机数量declare -i unactive_sum=0
// for 循环执行ping主机测试for i in {1..254}; doif ping -c 1 -w 1 "$host_pre.$i" &>/dev/null; thenecho -e "33 $host_c.$i is active. 33//在线主机数量+1active_sum=$active_sum+1else//不在线主机数量+1echo -e "33 $host_pre.$i is unactive. 33unactive_sum=$unactive_sum+1
fidone
//打印在线主机数量echo -e "33//打印不在线主机的数量echo -e "33
exit 0
页:
[1]