简体   繁体   English

获取第 19 行:语法错误:意外的文件结尾

[英]Getting line 19: syntax error: unexpected end of file

I'm trying to associate the Elastic IP address with Auto scaling group, so whenever the autoscaling triggers it will automatically associate with the EIP.我正在尝试将 Elastic IP 地址与 Auto scaling 组相关联,因此只要自动缩放触发,它就会自动与 EIP 相关联。

For this I'm trying to add the script in user data.为此,我试图在用户数据中添加脚本。

My intention is to we have 2 servers so its associated with 2 EIP's, whenever the autoscaling triggers it has to check whether the EIP is free or not if its free it has to associate with that instance using the instance id.我的意图是我们有 2 个服务器,因此它与 2 个 EIP 相关联,每当自动缩放触发时,它必须检查 EIP 是否空闲,如果空闲,它必须使用实例 ID 与该实例相关联。

So when i run the script im getting line 19: syntax error: unexpected end of file.因此,当我运行脚本时,我得到第 19 行:语法错误:文件意外结束。 I have checked the indentations but i think its correct.我检查了缩进,但我认为它是正确的。

#!/bin/bash
INSTANCE_ID=$(ec2-metadata --instance-id | cut -d " " -f 2);
EIP_LIST=(eipalloc-07da69856432f7cef eipalloc-0355263fcb50412ed)
for EIP in $${EIP_LIST}; do
        echo"Checkin if EIP is free"
        ISFREE=$(aws ec2 describe-addresses --allocation-ids $EIP --query Addresses[].InstanceID --output text --region ap-south-1)
        STARTWAIT=$(date +%s)
        while [ ! -z "$ISFREE" ]; do
                if [ "$(($(date +%s) - $STARTWAIT))" -gt $MAXWAIT ]; then
                        echo "WARNING: We waited for 30 seconds, we are forcing it now."
                        ISFREE=""
                else
                        echo "checking the other EIP [$EIP]"
                        ISFREE=$(aws ec2 describe-adresses --allocation-ids $EIP --query Addresses[].InstanceID --output text --region ap-south-1)
                fi
        done
        echo "Running: aws ec2 associate-address --instance-id $INSTANCE_ID --allocation-id $EIP --allow-reassociation --region ap-south-1"
        aws ec2 association-address --instance-id $INSTANCE_ID --allocation-id $EIP --allow-reassociation --region ap-south-1




You are missing the final done for the for -loop.您错过了for循环的最终done

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 出现语法错误:运行“立即执行”时意外的关键字 END - Getting Syntax Error: Unexpected keyword END while running `Execute Immediate` 将 CSV 转换为 jSON - 不断出现“预期文件结束”错误 - Converting CSV to jSON - Keep getting "End of File expected" error 语法错误:预期的输入结束但在 - Syntax error: Expected end of input but got "(" at PHP 解析错误:语法错误,意外标识符“AnsiColorMode” - PHP Parse error: syntax error, unexpected identifier "AnsiColorMode" 使用 flutterfire 配置时出现意外的输入错误结束 - Unexpected end of input error when configuring with flutterfire 在 object DriveApp.File 上获取方法或属性 moveTo 时出现意外错误 - Unexpected error while getting the method or property moveTo on object DriveApp.File Multer 错误:Multipart._final 处出现意外的表单结尾 - Multer Error: Unexpected end of form at Multipart._final [Amazon](500310) 无效操作:输入末尾的语法错误 Position: 684; - [Amazon](500310) Invalid operation: syntax error at end of input Position: 684; 语法错误:应为“(”或“,”或关键字 SELECT 但脚本结束 - Syntax error: Expected "(" or "," or keyword SELECT but got end of script 语法错误:预期输入结束但在 BigQuery 中获得了标识符 - Syntax error: Expected end of input but got identifier in BigQuery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM