1. 程式人生 > >shell 腳本檢測端口狀態

shell 腳本檢測端口狀態

done txt clas lse amp ech lin while class

方法一:

# 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

shell 腳本檢測端口狀態