0

I use a pipelined command in an alias to start a docker server (e.g alias ent="echo -e '\n';docker-compose up|grep --color ERROR").

The server sometimes asks me a question, to which I should input y or n. I always enter y.

How can I add it to my pipelined command?

  • It depends somewhat on what it is that asks the question and from where it's expecting to read the answer. Is it reading from the standard input of docker-command, you could possibly just use echo 'y' | docker-compose .... – Kusalananda Jan 22 '19 at 9:43
1

Looks like a perfect job for the yes command!

From the manpage:

DESCRIPTION
Repeatedly output a line with all specified STRING(s), or 'y'.

That means that a simple yes outputs y indefinitely.

I suppose is docker-compose up which need "yes" input, so you can use something like

alias ent="echo -e '\n';yes | docker-compose up | grep --color ERROR"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.