Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

251
Visualizações
aws cli output automatically being sent to vi

I am currently learning the AWS CLI (v2) and have installed it on Ubuntu 18.04. I am running zsh with oh-my-zsh installed. I am trying to get aws command output to be reported back to the terminal as a JSON string (or even as text), but the output is always redirected to vi.

My AWS account is brand new - no EC2 instances. When I run the following command:

aws ec2 describe-instances

It sends the expected output value (e.g. { "Reservations": [] }), but directly to vi instead of outputting a JSON string to the terminal requiring closing vi afterwards. This occurs regardless of output format (json, text, table) or what shell I use (bash, zsh).

I am not sure if this is a AWS CLI configuration issue/change or a shell/Linux configuration issue/change

  • I've reviewed my .zshrc, .bashrc, .bash_profile and .bash_aliases files and have not seen any obvious solution here that would change or redirect output.
  • I've been scouring the AWS CLI documentation, Stack Overflow and Google and I have not found a fix or a similar case.

Thank you for any/all suggestions.

over 4 years ago · Santiago Trujillo
5 Respostas
Responde à pergunta

0

There is a document on AWS with the title Controlling Command Output from the AWS CLI. According to this doc, the correct syntax should be

aws ec2 describe-instances --output json
over 4 years ago · Santiago Trujillo Relatório

0

I recommend either creating a new user account and/or going into a subshell without profile and trying to run your AWS command again. For example...

username:~$ sudo -u `whoami` bash --noprofile
# Now it drops us into a sub-shell with no /etc/profile or any scripts
bash-3.2$ aws ec2 describe-instances

This above drops you into a subshell that doesn't have any profile (/etc/profile or .bash_profile) files included. It should be pristine. From here we try your command again, and see what it does. I would guess here it would work fine and not drop you into VI. If so, then you need to look elsewhere for what bash/zsh is including (eg: /etc/profile) that is causing this to happen.

NOTE: If this does NOT fix your problem, your issue might be in the ~/.aws folder, I would wipe that folder out and start from scratch, re-run aws configure and then try your command again.

over 4 years ago · Santiago Trujillo Relatório

0

It was the PAGER environment variable set to "less" (which I was confusing with vi).

This fix is to update the ~/.aws/config file and setting cli_pager to an empty value, e.g. :

[default]
region = us-west-2
output = json
cli_pager =

Thank you to Sorin who commented on my question lead me to the answer.

over 4 years ago · Santiago Trujillo Relatório

0

Just run your command with --no-cli-pager like so

aws ec2 describe-instances --no-cli-pager

over 4 years ago · Santiago Trujillo Relatório

0

You can also run a one liner command:

aws configure set cli_pager ""
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda