文本:
#!/bin/bash
#Author:wangergui QQ:291131893 Email:[email protected]
#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
时间: 2024-10-16 00:08:12