站长资讯网
最全最丰富的资讯网站

脚本判断哪些IP地址可用

功能:通过shell脚本,批量读取文本中的IP,找出哪些IP地址已被使用

1、准备一个文本:touch allzip

添加部分IP地址

2、编写shell脚本:touch pingIP.sh (通过数据丢失率)

  #! /bin/bash  for i in `cat allip`  do  ping=`ping -c 1 $i | grep loss |awk '{print $6}' |awk -F "%" '{print $1}'`  if [ $ping -eq 100 ];then  echo ping $i fail  else  echo ping $i ok  fi  done

2、为文件赋权限,再执行文件

  chmod 777 pingIP.sh  sh pingIP.sh

赞(0)
分享到: 更多 (0)