批量nc检查端口存活

telnet.sh脚本内容

cat telnet.sh

#/bin/bash

cat testport | while read line
do

#nc -z -w 10 $line

nc -z -w 10 $line > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo $line:ok
else
echo $line:fail
fi

done

-----

目标ip和端口

cat testport

128.14.227.36 7001
128.14.227.36 7002
128.14.227.36 7003

a.b.com 13200
a.b.com 13201

--

执行动作

sh telnet.sh testport

--

posted @ 2020-03-20 22:27  qinliang  阅读(592)  评论(0编辑  收藏  举报