【发布时间】:2016-10-25 17:16:35
【问题描述】:
我正在尝试运行这个 aws s3 ls 命令:
aws s3 ls s3://path/to/my/bucket/12434 --recursive --human-readable --summarize
用这条蟒蛇:
command = 'aws s3 ls s3://path/to/my/bucket/12434 --recursive --human-readable --summarize'
s3_folder_data = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
print s3_folder_data
但它失败并出现此错误:
subprocess.CalledProcessError: Command 'aws s3 ls s3://path/to/my/bucket/12434 --recursive --human-readable --summarize' returned non-zero exit status 1
当我运行它时,该命令本身就起作用了。同一台机器上的同一用户正在调用 python 脚本。什么给了?
【问题讨论】:
-
有一个用于aws的python api叫做boto2,用它代替
-
这里是 s3 的链接 - boto.cloudhackers.com/en/latest/ref/s3.html
-
谢谢,我知道了。但这应该是一个快速而肮脏的脚本。如果我可以使用 CLI,我不想经历配置 boto 的麻烦。
-
没有问题,就是这样,使用起来非常简单,顺便看看我链接的另一个问题
-
你在开玩笑吗? get_bucket() 并列出它
标签: python amazon-web-services amazon-s3 aws-cli