1、整理好待测试的目标IP 及对应端口号,存为本地文本文件
183.61.160.67 10024
183.61.160.74 10009
119.147.128.173 10006
183.61.160.84 10011
119.147.107.203 10013
183.61.160.67 10015
183.61.160.58 10016
183.61.160.56 10010
183.61.160.74 10018
183.61.160.121 10015
youxi1
2、安装好tcping工具
Tcping 相关参数
tcping, (C) 2003 folkert@vanheusden.com
-h hostname hostname (e.g. localhost)
-p portnr portnumber (e.g. 80)
-c count how many times to connect
-i interval delay between each connect
-f flood connect (no delays)
-q quiet, only returncode
3、Shell 编写
#!/bin/bash
i=/home/admin/test/youxi1
cat $i |
while read line
do
host=echo $line | awk -F ' ' '{print $1}'
port=echo $line | awk -F ' ' '{print $2}'
tcping -h $host -p $port -c 10 -i 0.5
done
保存为 tcping.sh
注:echo $line | awk -F ' ' '{print $2}'
echo $line | awk -F ' ' '{print $2}'
要用单引号引起来
4、执行 bash tcping.sh
转载于:https://blog.51cto.com/lihongweibj/2298153