S
S
SeoNk2017-03-27 16:31:48
bash
SeoNk, 2017-03-27 16:31:48

How to make automatic Y/N response in Bash script?

There is a bash script script.sh
During its execution, a prompt appears, which must be answered with y / n:
For example:
default: Are you sure you want to destroy the 'default' VM? [y/N]
Tell me how to tell the script to automatically answer "y" ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2017-03-27
@saboteur_kiev

1. If the script is your own, you can edit it to find where it asks and remove the extra question.
2. echo "Y" | script.sh
3. If the script asks different things, you can throw the answers into a file, for example, the answers.txt file:
yes
yes
no
and execute
script.sh < answers.txt

X
xibir, 2017-03-27
@xibir

yes | script.sh

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question