【发布时间】:2016-03-16 18:31:32
【问题描述】:
我用case编写了bash脚本,当我按照./myscript.sh us-west-1d运行它时会导致错误
./myscript.sh: line 26: : command not found
./myscript.sh: line 27: : command not found
./myscript.sh: line 28: : command not found
ami-fce3c696 us-east-1
但是,当我运行./myscript.sh us-west-1b时,它运行正常
谁能告诉我如何解决这个问题?
#! /bin/bash
AZ=$1
case $AZ in
us-east-1b)
SUBNET="subnet-2a3b5d47"
SECURITY_GROUP=sg-f7d52998
INVENTORY_GROUP=collector-use1
WEIGHT=100
AMI=ami-fce3c696
REGION=us-east-1
;;
us-east-1d)
SUBNET="subnet-e6385e8b"
SECURITY_GROUP=sg-f7d52998
INVENTORY_GROUP=collector-use1
WEIGHT=100
AMI=ami-fce3c696
REGION=us-east-1
;;
us-east-1e)
SUBNET="subnet-07395f6a"
SECURITY_GROUP=sg-f7d52998
INVENTORY_GROUP=collector-use1
WEIGHT=100
AMI=ami-fce3c696
REGION=us-east-1
;;
esac
echo $SUBNET $SECURITY_GROUP $INVENTORY_GROUP $AMI $REGION
【问题讨论】:
-
你拼错了
esac。 -
哦,那是我的错字。但是,错误仍然是一样的
-
我怀疑这是 stackoverflow.com/q/31885409/1126841 的副本:为什么正确的 shell 脚本会给出包装/截断/损坏的错误消息?。
-
我相信我的问题和他的问题没有关系
-
您发布的代码很好。请检查 DOS 行尾,因为它是唯一可以解释发布的代码如何产生与您报告的错误类似的错误