【问题标题】:Why aws --version writes to stderr?为什么 aws --version 写入标准错误?
【发布时间】:2017-05-16 23:41:10
【问题描述】:

为什么标准检查aws --version 将预期输出打印到标准错误,而不是标准输出?

$ aws --version 2>err.log
$ cat err.log
aws-cli/1.11.65 Python/2.7.13 Darwin/16.5.0 botocore/1.5.28
$ aws --version > out.log
aws-cli/1.11.65 Python/2.7.13 Darwin/16.5.0 botocore/1.5.28
$ cat out.log
$

如果命令成功完成,将结果写入标准输出是有意义的。 aws ec2 describe-imagesaws ec2 describe-instances 等其他命令将输出正确写入标准输出。

在 CentOS 和 MacOS 上检查。

【问题讨论】:

标签: amazon-web-services amazon-ec2 aws-cli


【解决方案1】:

这是由 Python 3.4 中修复的 bug in argparse 引起的。

awscli 是用 Python 编写的,它使用 argparse module 来解析命令行。它还使用了argparse的action="version"feature来简化版本打印。这会将版本字符串打印到 Python 3.4 之前的 stderr,并在 Python 3.4+ 中打印到 stdout。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-19
    • 2023-03-15
    • 1970-01-01
    • 2017-06-10
    • 2014-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多