nc命令检查端口是否存活
#!/bin/bash
for IP in `cat /log/ip_ubt.txt`
do
IPP="$IP 22"
/bin/nc -v -w 5 -z $IPP > /dev/null 2>&1
if [ $? -eq 0 ];then
echo $IPP:ok >> /log/ssh_22_ok.txt
echo $IP >> /log/ssh_22.txt
fi
done
本文转自linux博客51CTO博客,原文链接http://blog.51cto.com/yangzhiming/1900836如需转载请自行联系原作者
yangzhimingg