telnet测试.sh
#!/bin/bash host=$1 function getConnection() { telnet $1 22 &>/dev/null if [ $? != 0 ];then echo -e "\n无法连接到 $1" continue else echo -e "\n成功连接到 $1" fi } #getConnection $User $filename for line in `cat $host` do getConnection $line done
#!/bin/bash host=$1 function getConnection() { telnet $1 22 &>/dev/null if [ $? != 0 ];then echo -e "\n无法连接到 $1" continue else echo -e "\n成功连接到 $1" fi } #getConnection $User $filename for line in `cat $host` do getConnection $line done