我是Shell脚本的新手,但是我试图解析命令输出并将这些id值存储为数组。
C:\Users\Shruthi>aws ecs list-tasks --cluster test-cluster --service hello2-service
{
"taskArns": [
"arn:aws:ecs:ap-south-1:822063991960:task/6990efe7-4a81-4fe7-8d25-d1ec1898971e","arn:aws:ecs:ap-south-1:822063991960:task/0281508f-4d90-4ebc-afcd-684f58f5405e"
]
}
我想将上述taskArns存储到一个数组变量中,
taskArn = (arn:aws:ecs:ap-south-1:822063991960:task/6990efe7-4a81-4fe7-8d25-d1ec1898971e arn:aws:ecs:ap-south-1:822063991960:task/0281508f-4d90-4ebc-afcd-684f58f5405e ..)
等,以便我可以进一步使用此任务ID来描述特定任务并找到其当前状态。
我实现了答案的方法,但是我无法使用$ line变量值进行命令替换,
echo $FOO | while read -r line; do
name="$line"
echo "Name read from file - $name"
#Successfully describes
val="arn:aws:ecs:ap-southeast-1:296646925901:task/4d2bf627-82f5-45c7-8ad4-60b9e2f1934a"
aws ecs describe-tasks --cluster mol-dev-cluster --tasks $val
#Errors out
aws ecs describe-tasks --cluster mol-dev-cluster --tasks $line
done
导致以下错误
error 14-Nov-2019 11:25:12 An error occurred (InvalidParameterException) when calling the Describetasks operation: taskId length should be one of [32,36]
simple 14-Nov-2019 11:25:12 Failing task since return code of [/tmp/runInDocker4657237329652069100.sh /home/bamboo/bamboo-agent-home/temp/47349848-46924268-46636883-ScriptBuildTask-5580550432412549027.sh] was 255 while expected 0