Espere automatizar resposta sim ao CLI

3

Quando eu executo o comando ambari-server upgrade de um script bash, no meio da atualização nós recebemos a pergunta

have made a backup of the Ambari Server database [y/n] (y)?

assim, queremos automatizar o processo, esperando que o script envie yes quando a pergunta chegar.

Por favor, informe como automatizar o ambari-server upgrade por esperar

ambari-server upgrade

Using python  /usr/bin/python
Upgrading ambari-server
INFO: Upgrade Ambari Server
INFO: Updating Ambari Server properties in ambari.properties
...
WARNING: Can not find ambari.properties.rpmsave file from
previous version, skipping import of settings
INFO: Updating Ambari Server properties in ambari-env.sh ...
INFO: Can not find ambari-env.sh.rpmsave file from previous
version, skipping restore of environment settings. ambari-env.sh may not
include any user customization.
INFO: Fixing database objects owner
Ambari Server configured for Embedded Postgres. Confirm you     

have made a backup of the Ambari Server database [y/n] (y)?

INFO: Upgrading database schema
INFO: Return code from schema upgrade command, retcode = 0
INFO: Console output from schema upgrade command:
INFO: {"lzo_enabled":"false"}
INFO: Schema upgrade completedAdjusting ambari-server permissions and ownership...
Ambari Server 'upgrade' completed successfully.
    
por yael 21.02.2018 / 18:22

1 resposta

6

Você pode canalizar yes para seu script:

yes | ambari-server upgrade

Isso fará com que todos os pedidos sejam respondidos com y .

    
por 21.02.2018 / 18:26