作者:ahhylwjj | 来源:互联网 | 2023-05-18 16:38
#!binbash-x.etcinit.dfunctionsm192.168.137.array($(seq10))fornin${array[@]}doip${m}${n}[`p
#!/bin/bash -x
. /etc/init.d/functions
m=192.168.137.
array=(
$(seq 10)
)
for n in ${array[@]}
do
ip=${m}${n}
[ `ping -c4 ${ip}|wc -l` -eq "9" ]||{
logfile=$(date +%F).${ip}.log
touch /tmp/$logfile
echo "${ip} is disconnected!" >/tmp/$logfile
action "${ip}" /bin/false
}&&{
action "${ip}" /bin/true
}
done
本文出自 “神奇的海螺” 博客,谢绝转载!
检测一个网段多个主机网络是否正常(使用数组)