1. 程式人生 > >批量Tcping ip 加 端口

批量Tcping ip 加 端口

only don $1 count tcp 參數 ber 3.6 print

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 [email protected]

-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

4、執行 bash tcping.sh

批量Tcping ip 加 端口