檢測一個網段多個主機網絡是否正常(使用數組)

#!/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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章