批量发ping
#! /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
allip
10.5.160.26
10.5.160.27
10.5.160.28
10.5.47.220
10.5.47.221
10.5.47.222
10.5.47.223
10.5.47.224
批量检测端口
#!/bin/bash
cat ./ip-ports.txt | while read line
do
nc -w 10 -z $line > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo $line:ok
else
echo $line:fail
fi
done
10.5.160.27 554
10.5.160.28 554
10.5.47.220 554
10.5.47.221 554
10.5.47.222 554
10.5.47.223 554
10.5.47.224 554
网友评论