Calendar
数据载入中,请稍候......
Placard
数据载入中,请稍候......
Category
数据载入中,请稍候......
Latest Entries
数据载入中,请稍候......
Latest Comments
数据载入中,请稍候......
Last Messages
数据载入中,请稍候......
User Login
数据载入中,请稍候......
Links
Information
数据载入中,请稍候......
Search
Other


Welcome to my blog!
  shell定时ping主机脚本
  #!/bin/bash
#ping /etc/hosts
#Author HaHaZhu
#12/22/06 6:20
Curdate=`date +%d%m%y`
CurPath='/tmp'
trap "delfile" 2
function delfile(){
if rm -f $CurPath/result.$Curdate ;then
 echo "Del result.$Curdate ok"
 exit 1
else
 echo "program error~please check!"
 exit 1
fi
}
for Loop in `cat /etc/hosts|grep -v "^#"|cut -f1`
do
 ping -s 1000 -c1 $Loop>$CurPath/result.$Curdate
 echo "Now,read?[y|n]"
 read NFS
 case $NFS in
 y|Y)
   Vue=`cat /tmp/result.$Curdate|sed -n '2p'`
   if [ "$Vue" = "" ];then
     echo "$Loop shutdown!"
   else
     echo $Vue
   fi
    ;;
 n|N)
    ;;
 esac
rm -f $CurPath/result.$Curdate
done
====================
linux用来自动ping /etc/hosts主机的.写出来供那些网管使用...嘿嘿....帮测试下吧.
[ 阅读全文 | 回复(0) | 引用通告 | 编辑

  Post  by  badboy 发表于 2006-12-22 5:25:00
发表评论:
数据载入中,请稍候......
数据载入中,请稍候......