- Newest
- Most votes
- Most comments
here are some ways i have found on another thread related to this:
use the aws.exe executable directly from the command line. For example, you could run the following command to list the objects in the pics-repository bucket:
aws.exe s3api list-objects-v2 --bucket pics-repository --query Contents[*].Key --max-items 10 Another way to work around this issue is to use the Invoke-Expression cmdlet in PowerShell. For example, you could run the following command to list the objects in the pics-repository bucket:
Invoke-Expression "aws s3api list-objects-v2 --bucket pics-repository --query Contents[*].Key --max-items 10"
Finally, you could also use the aws-cli.exe executable to run your batch file. This executable will create a Windows console and execute your batch file in the context of the AWS CLI. However, this executable is not officially supported by AWS, so you may experience some unexpected behaviour.
Hello,
After some investigations I found out that the solution would be to add the option --no-cli-auto-prompt
to the AWS CLI command:
for /f "tokens=*" %%a in ('aws s3api list-objects-v2 --bucket pics-repository --no-cli-auto-prompt --query Contents[*].Key --max-items 10 ') do set _CmdResult=%%a
It seams that the blocking option in the CLI command (that waits for user input) is not well-understood by Windows cmd.
Have a good day,
Mihai ADAM
Relevant content
- asked 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
Hello,
To give you a bigger picture of the problem, I could say that I'm trying to pipe some aws commands, but none of the above solutions works. Did I mistake some wording or is the piping impossible with aws cli environment ?
The solution that I'm looking for, looks something like below:
Windows cmd: for /f "tokens=" %%a in ('aws s3api list-objects-v2 --bucket pics-repository --query Contents[].Key --max-items 10') do set _CmdResult2=%%a aws s3api get-object-tagging --bucket pics-repository --key %_CmdResult2%
Windows PS: Invoke-Expression "aws s3api list-objects-v2 --bucket pics-repository --query Contents[*].Key --max-items 2" | "aws s3api get-object-tagging --bucket pics-repository --key Key"
But none of the above works with the same error: "No Windows console found. Are you running cmd.exe?". Can AWS CLI be used in such a way ?
Thank you, Mihai