文本:
#!/bin/bash
#Author:wangergui QQ:291131893 Email:291131893@qq.com
#Release 1.0
#Function: Check LAN which IP online
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:~/bin
[[ -f /etc/init.d/functions ]] && . /etc/init.d/functions || exit 3
function check_ip () {
trap 'exit' SIGINT
Network="192.168.3"
Num=1
while [[ ${Num} -le 10 ]];do
ping -c 1 -W 1 ${Network}.${Num} >/dev/null 2>&1
[[ $? -eq 0 ]] && action "${Network}.${Num} is online" /bin/true || action "${Network}.${Num} is offline" /bin/false
let Num++
done
}
check_ip
本文转自 wangergui 51CTO博客,原文链接:http://blog.51cto.com/wangergui/1880543,如需转载请自行联系原作者