#!/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
本文出自 “神奇的海螺” 博客,谢绝转载!
原文地址:http://bilishell.blog.51cto.com/11756401/1841268