Bash 如何检查AWS CLI--干运行是否会在脚本中成功?

Bash 如何检查AWS CLI--干运行是否会在脚本中成功?,bash,amazon-web-services,aws-cli,Bash,Amazon Web Services,Aws Cli,我使用各种bash脚本来简化日常操作。有时我在运行它们时忘记了获取会话令牌,所以我想我应该在脚本的早期添加一些--dry run命令。我原以为一个操作会输出: A client error (DryRunOperation) occurred when calling the DescribeInstances operation: Request would have succeeded, but DryRun flag is set. …将以0退出-毕竟,它在提供的参数方面是成功的-但它以

我使用各种bash脚本来简化日常操作。有时我在运行它们时忘记了获取会话令牌,所以我想我应该在脚本的早期添加一些
--dry run
命令。我原以为一个操作会输出:

A client error (DryRunOperation) occurred when calling the DescribeInstances operation: Request would have succeeded, but DryRun flag is set.
…将以
0
退出-毕竟,它在提供的参数方面是成功的-但它以
255
退出

当您看到当您没有运行命令的权限时的输出以相同的错误代码退出时,问题会变得更糟。
255

A client error (UnauthorizedOperation) occurred when calling the DescribeInstances operation: You are not authorized to perform this operation.
(糟糕)检查实际输出值“requesthavesuccessed”的唯一解决方案是,还是有更优雅的解决方案?我根本看不出这背后的逻辑


谢谢

是的,您需要检查输出。

它确实回答了问题
是(糟糕)检查实际输出值“Request have successed”的唯一解决方案,还是有更优雅的解决方案?
答案是没有更优雅的解决方案,他们必须检查输出。您的答案看起来像是评论,抱歉。看来你是对的。我将删除我的评论。