On 2015-11-13, BeeRich <
bee...@gmail.com> wrote:
> Hi folks.
>
> I wrote a bash script that updates gems and reports the status of an
> application, etc. During the status check, it asks me a question, which
> always requires a carriage return. How can I modify my script to
> automatically send a carriage return when that prompt arrives?
If a program reads something from standard input, you can pipe it in:
echo answer | program_which_asks_question
If a program asks "are you sure, [y/n]? " numerous times, the yes utility
can generate all the y answers:
yes | program_asking_yes_or_no
With some programs, redirecting to their standard input won't work, because
some programs open the controlling TTY device and use it directly.
To automate such programs you need the expect utility, or something similar.
The expect utility creates a fake terminal session around a pseudo TTY
device, and runs the program in that session. Your expect script
carries out a TTY conversation with the program through the master side
of the pseudo TTY.