ITPub博客

首页 > 移动开发 > HTML5 > shell脚本实现信用盘程序制作快速ping网段内的IP地址

shell脚本实现信用盘程序制作快速ping网段内的IP地址

HTML5 作者:oasanmu 时间:2019-09-10 17:01:38 0 删除 编辑

想看网段中有哪些IP被用了,信用盘程序制作q<115.28.8.00.9.9>可以用这个快速ping做一个初步的判断。可以自己指定测试IP网段,并将测试结果整理排序到文件。




#!/bin/bash


#V1.0 2019-09-10


#Ping test shell script by tutor




clear


>ip-up.txt


>ip-down.txt




while true;


 do


    read -p "Please input the ip segment for ping test(like 192.168.100) : "  segment






     if [ -z $segment  ] ; then




       segment="192.168.100"




     fi






    echo -n "the ip segment is ${segment} , are you sure to continue [y/n] ? "




    read  action




     if [ -z $action  ] ; then


          break


     fi




     if [  "$action" =  "y"  ]; then


         break


     fi


done




echo "ping test is ready to run! "




for i in  {1..254}


 do


      {


        ping -c2 -W1 ${segment}.${i}  &>/dev/null


        if [ $? -eq 0 ]; then


           echo "${segment}.$i is up" &>/dev/null  >> ip-up.txt


        else


           echo "${segment}.$i is down" &>/dev/null >> ip-down.txt


        fi


     }&


done




wait


            sort -n -k 4 -t . ip-up.txt -o ip-up.txt


            cat ip-up.txt


            sort -n -k 4 -t . ip-down.txt -o ip-down.txt


            cat ip-down.txt




echo "ping test are finished!"


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69948068/viewspace-2656652/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2019-09-10

  • 博文量
    1
  • 访问量
    665