pingall脚本
p i n g a l l:一個(gè)按照/ e t c / h o s t s文件中的條目逐一p i n g所有主機(jī)的腳本
它能夠按照/ e t c / h o s t s文件中的條目逐一p i n g所有的主機(jī)。該腳本列出/ e t c / h o s t s文件并查找其中的非注釋行(不以#開頭的行)。然后使用一個(gè)w h i l e循環(huán)讀入所有的行,接下來使用a w k分析出每行的第一個(gè)域,并把它賦給變量A D D R。最后使用f o r循環(huán)逐一p i n g相應(yīng)的地址。
#!/bin/sh
#pingall
cat /etc/hosts|grep -v "^#"|while read LINE
do
ADDR=`awk '{print $1}'`
for MACHINE in $ADDR
do
ping -s -c $MACHINE
done
done
轉(zhuǎn)載于:https://www.cnblogs.com/seasonsstory/p/3314594.html
總結(jié)
- 上一篇: 建议15: 使用dynamic来简化反射
- 下一篇: hdu 4717 The Moving