Linux 在bash脚本上使用数组时发生aws cli错误

Linux 在bash脚本上使用数组时发生aws cli错误,linux,bash,aws-cli,Linux,Bash,Aws Cli,我一直在尝试创建一个脚本来重新启动失败的ec2实例,但它会给我一个错误,如: A client error (InvalidCharacter) occurred when calling the RebootInstances operation: Your request contains an invalid XML character and can not be processed 我正在创建一个失败的ec2实例ID数组,然后将其传递到aws cli进行工作 if [ ${#inst

我一直在尝试创建一个脚本来重新启动失败的ec2实例,但它会给我一个错误,如:

A client error (InvalidCharacter) occurred when calling the RebootInstances operation: Your request contains an invalid XML character and can not be processed
我正在创建一个失败的ec2实例ID数组,然后将其传递到aws cli进行工作

if [ ${#instances_to_reboot[@]} -gt 0 ]; then
    echo "rebooting instances"
    aws ec2 reboot-instances --instance-ids $(echo ${instances_to_reboot[@]}) --dry-run
else
    echo "no instances to reboot"
fi
我注意到如果使用

aws ec2 reboot-instances --instance-ids $(echo ${instances[@]}) --dry-run

在终端上,它可以工作。。所以我不知道我做错了什么

如果只使用echo替换aws命令,结果是什么?你是说像
aws ec2重新启动实例--instance ids$(echo$instances)--干运行
?它只会打印实例[0],它会给我同样的错误否,我的意思是当您在脚本中的某一点执行
echo${instances\u to_reboot[@]}
时打印的内容。它打印类似于
I-8d5ef1d1 I-78febaed I-d20b4e78
Hmmm。。。。如果将
--debug
附加到命令,它将打印调试日志。作为其中的一部分,它应该打印通过线路发送的参数以及cli接收的内容。擦洗时,请不要更改任何非字母数字字符。我感觉有一个长长的破折号正在发送。如果只使用echo替换aws命令,结果会是什么?你是说像
aws ec2重新启动实例--instance ids$(echo$instances)--干运行
?它只会打印实例[0],它会给我同样的错误否,我的意思是当您在脚本中的某一点执行
echo${instances\u to_reboot[@]}
时打印的内容。它打印类似于
I-8d5ef1d1 I-78febaed I-d20b4e78
Hmmm。。。。如果将
--debug
附加到命令,它将打印调试日志。作为其中的一部分,它应该打印通过线路发送的参数以及cli接收的内容。擦洗时,请不要更改任何非字母数字字符。我有一种感觉,一个长破折号正在发送。