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

 

posted @ 2020-04-14 15:09  破仔  阅读(195)  评论(0编辑  收藏  举报