Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 有没有一种方法可以将变量与用于SNS的AWS CLI一起使用?_Amazon Web Services_Shell_Command Line Interface_Amazon Ses - Fatal编程技术网

Amazon web services 有没有一种方法可以将变量与用于SNS的AWS CLI一起使用?

Amazon web services 有没有一种方法可以将变量与用于SNS的AWS CLI一起使用?,amazon-web-services,shell,command-line-interface,amazon-ses,Amazon Web Services,Shell,Command Line Interface,Amazon Ses,我使用aws cli通过sns发送一些电子邮件,在我运行的shell脚本中,我声明了一些变量,STATUS_DOWN_HOST和STATUS_DOWN_ENV。然后,我的脚本的主要“部分”运行以下命令: aws sns发布——主题arn arn:aws:sns:ap-southwest-2:377766644499:URL_测试--消息“The 服务$STATUS\u DOWN\u主机对$STATUS\u DOWN\u ENV没有响应。“ 这会按预期发送邮件,但变量未被拾取,因此电子邮件消息只会

我使用aws cli通过sns发送一些电子邮件,在我运行的shell脚本中,我声明了一些变量,STATUS_DOWN_HOST和STATUS_DOWN_ENV。然后,我的脚本的主要“部分”运行以下命令:

aws sns发布——主题arn arn:aws:sns:ap-southwest-2:377766644499:URL_测试--消息“The 服务$STATUS\u DOWN\u主机对$STATUS\u DOWN\u ENV没有响应。“

这会按预期发送邮件,但变量未被拾取,因此电子邮件消息只会显示,而忽略了这些部分

是否应该使用一些引号或括号,以便cli拾取变量


谢谢

您可以使用
printenv
命令将环境变量包括到输出中

$()语法将允许您嵌入命令

aws sns publish --topic-arn arn:aws:sns:ap-southwest-2:377766644499:URL_TEST --message "The service $(printenv STATUS_DOWN_HOST) is unresponsive on $(printenv STATUS_DOWN_ENV)."
参考资料



您是否尝试通过运行
echo“服务$STATUS\u DOWN\u主机在$STATUS\u DOWN\u ENV上没有响应”来测试VAR是否已设置。
?我已经测试了相同的设置,并且成功了。检查变量。即使在说:导出状态\u DOWN\u HOST=myhost.com导出状态\u DOWN\u ENV=INT\u测试之后