#!/bin/bash
ipAddArray=([0]="192.168.1.101" [1]="192.168.1.254")
ip_right_or_not()
{
remoteIpAddr=$1
if [ "$remoteIpAddr" != "" ]
then
i=0
while (( i<${#ipAddArray[*]} ))
do
if [ $remoteIpAddr = ${ipAddArray[i]} ]
then
return 0
fi
let "i++"
done
return 1
else
return 1
fi
}
echo "Please input the ip address"
read ipAddr
if ip_right_or_not $ipAddr
then
echo "Connecting to $ipAddr..."
ssh root@$ipAddr
else
echo "what you input is null or wrong"
fi
阅读(1823) | 评论(0) | 转发(0) |