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

 

转载于:https://www.cnblogs.com/miclesvic/p/10281193.html

你可能感兴趣的:(shell 脚本检测端口状态)