Chinaunix首页 | 论坛 | 博客
  • 博客访问: 267590
  • 博文数量: 103
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 705
  • 用 户 组: 普通用户
  • 注册时间: 2013-05-02 16:15
文章分类

全部博文(103)

文章存档

2014年(8)

2013年(95)

我的朋友

分类: 系统运维

2014-03-13 16:47:07

#!/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
阅读(1778) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~