I am trying to save AWS CLI command into python variable (list). The trick is the following code returns result I want but doesn't save it into variable and return empty list.
import os
bashCommand = 'aws s3api list-buckets --query "Buckets[].Name"'
f = [os.system(bashCommand)]
print(f)
output:
[
"bucket1",
"bucket2",
"bucket3"
]
[0]
desired output:
[
"bucket1",
"bucket2",
"bucket3"
]
("bucket1", "bucket2", "bucket3")