标签:contains list contain xxx this bre after ssh 脚本
#! /bin/bash
# @author
# @breif auto ssh
function show_usage(){
echo -e "=================This is Usage====="
echo -e " -h: which host to go,for example dev041"
}
function show_hostlist(){
echo "dev357 => xxxxx"
echo "45 => xxxxx"
}
function ssh_fun(){
if [ $# -ne 1 ];then
show_hostlist
fi
case "$1" in
"a" ) ssh zhaoyixing@x.xxxx.com ;;
"b" ) ssh zhaoyixing@x.xxxxx ;;
"*" ) ssh $1 ;;
esac
}
#ssh
if [ $# -eq 0 ];then
echo -e "\e[1;31mParams Error:\e[0m MayBe You Need Use -h"
show_usage
exit 0
fi
#1.The ":" after h mean that h can take values
#2.$OPTARG contains current value
host=‘‘
while getopts "h:" Option;do
case $Option in
h)ssh_fun $OPTARG ;;
*)show_usage ;;
esac
done
标签:contains list contain xxx this bre after ssh 脚本
原文地址:https://www.cnblogs.com/zhaoyixing/p/14670376.html