3

Is there a way to pipe the letter q into an aws cli command so that I don't have to press q when the function has finished? (Less about laziness, more about automation, which is arguably the same thing).

E.g. when I upload a Lambda function, the JSON response is returned, but I have to press q in order to trigger the automated uploading of a second function. I tried aws lambda.. | q but to no avail!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
timhc22
  • 7,213
  • 8
  • 48
  • 66
  • 2
    This might help: `echo "q" | aws lamda ...` – Cyrus Nov 13 '20 at 20:16
  • 3
    Is this because the awscli is forcing pagination on you because of lengthy results and you're trying to quit out of the pagination? You may be able to use `--no-cli-pager`. – jarmod Nov 13 '20 at 23:40

2 Answers2

8

AWS CLI v2 introduced a pager for command output. This allows requests to be halted early, rather than retrieving all data in one call.

From Using AWS CLI pagination options - AWS Command Line Interface:

AWS CLI version 2 provides the use of a client-side pager program for output. By default, this feature returns all output through your operating system’s default pager program.

You can disable all use of an external paging program by specifying: --no-cli-pager

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • Thanks for knowing what it was that I was actually looking for. `--no-cli-pager` didn't actually seem to work for me (maybe I need to update my cli, but it seems to be v2, so I need to look into that), `export AWS_PAGER=""` did however seem to help, as per here: https://stackoverflow.com/questions/60122188/how-to-turn-off-the-pager-for-aws-cli-return-value – timhc22 Nov 16 '20 at 13:11
  • 1
    I actually use `cli_pager=` in my `~/.aws/config` file. Does the same thing, at the profile level. – John Rotenstein Nov 17 '20 at 04:58
  • Even better! @John Rotenstein – timhc22 Nov 17 '20 at 05:47
1

TLDR

echo 'q' | { aws lambda.. }

Explanation

I believe the issue you are having may be similar to the problem in this post: Read values into a shell variable from a pipe.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Lenna
  • 1,220
  • 6
  • 22