扫描局域网ip的shell

# vim /mysh/ipscan.sh 

#!/bin/bash
# scan the local alive ipaddress
# 2016-09-24


if [ -f $filename ];then
   echo "the file is exist" 
 for n in {100..106};do
      host=192.168.0.$n
      ping -c2 $host &>/dev/null
      if [ $? = 0 ];then
         echo "$host is up"
         echo "$host" >> /root/alive.txt
      else
          echo "$host is Down"
      fi
   done
      echo "------------------`date +"%Y-%m-%d"`-------------------------------"
 else
   echo "the file is not exist"
   touch /root/alive.txt
fi

   

posted @ 2016-09-25 10:06  岁月童话  阅读(722)  评论(0编辑  收藏  举报