shell 脚本检测端口状态
方法一:
# cat check_port.sh #!/bin/bash cat ip.txt|while read line do /usr/bin/nc -w 1 -z $line > /dev/null 2>&1 if [ $? -eq 0 ] then echo telnet $line ok sleep 1 else echo telnet $line fail fi done # cat ip.txt 124.234.83.15 80 124.234.83.10 80