批量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
--