我正在使用 AWS 命令行工具运行一个简单的 S3 复制命令。我故意输入了一个不存在的桶名来测试失败并相应地处理它们。但是,在成功和不成功复制到 S3 时,我的返回代码都是 0(零)。这是正常行为还是错误?如果这是正常的,那么我如何在不必检查(即 grep)字符串值的标准输出(即“上传失败”)的情况下捕获错误?
复制成功
[ec2-user@ip-10-0-10-68 ~]$ aws s3 cp puppetmaster-bootstrap.sh s3://puppet-enterprise
upload: ./puppetmaster-bootstrap.sh to s3://puppet-enterprise/puppetmaster-bootstrap.sh
[ec2-user@ip-10-0-10-68 ~]$ echo $?
0
复制失败
[ec2-user@ip-10-0-10-68 ~]$ aws s3 cp puppetmaster-bootstrap.sh s3://puppe-enterprise | tee -a ${LOGFILE}
upload failed: ./puppetmaster-bootstrap.sh to s3://puppe-enterprise/puppetmaster-bootstrap.sh A client error (NoSuchBucket) occurred when calling the PutObject operation: The specified bucket does not exist
[ec2-user@ip-10-0-10-68 ~]$ echo $?
0
使用 CLI 版本:
[ec2-user@ip-10-0-10-68 ~]$ aws --version
aws-cli/1.3.17 Python/2.6.9 Linux/3.10.35-43.137.amzn1.x86_64
最佳答案
听起来像这样的应该发布到他们的 GitHub Issues 页面。
关于linux - AWS CLI S3 复制 (cp) 命令在成功和不成功尝试时都返回 0(零)状态代码 - 这是正确的行为吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24371288/