From a5835ab7d421c5062d054b5492c523c3f4050999 Mon Sep 17 00:00:00 2001 From: fulln <245193247@qq.com> Date: Thu, 3 Sep 2020 18:31:30 +0800 Subject: [PATCH] Update locate.sh --- ssh_script/locate.sh | 59 +++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/ssh_script/locate.sh b/ssh_script/locate.sh index d977bef..017856e 100755 --- a/ssh_script/locate.sh +++ b/ssh_script/locate.sh @@ -5,20 +5,16 @@ username="" passwd="" location="" -## 计数器 -index=1 ## 未输入参数 if [ -z "$1" ]; then echo "Usage: will be used default params" hostip="${hostip}24" -else - echo "listing args with \$*:" - for arg in $* - do - echo arg: $index = $arg - if [ $index == 1 ]; - then +else +while getopts ":ip:name:pass:pack:" arg +do + case $arg in + ip) len=$arg|wc -c if [ ${len} >4 ]; then @@ -26,22 +22,39 @@ else else hostip="$hostip$arg" fi - elif [ $index == 2 ]; - then + ;; + name) username=$arg - elif [ $index == 3 ]; - then - passwd=$arg - else [ $index == 4 ]; - location=$arg - fi - let index+=1 - done - echo - + ;; + pass) + passwd=$arg + ;; + pack) + location=$arg + ;; + ?) + echo "未知参数" + ;; + esac +done fi -echo $hostip $username $passwd $location +case $location in + "trans") + location="es-cabinet-transfer" + ;; + "act") + location="fcbox-activity-core" + ;; + "op") + location="fcbox-oplatform-admin" + ;; + ?) + echo "未知参数" + exit 22;; +esac -expect /Users/fulln/opt/sampleScrips/ssh_script/login.exp $hostip $username $passwd $location +echo $hostip $username $passwd $location + +expect $PWD/login.exp $hostip $username $passwd $location