Shell Script – How to Prepare Answers for Command Questions

shellshell-script

Let's say I want to write a shell script that executes just one command. But this command is poorly designed. It doesn't offer any command line options; instead it asks some questions and waits for user input.

Is there a way to prepare this input in the script, so the questions are answered automatically?

Best Answer

If the command is not very picky it should work with something like this:

command > /dev/null << EOF
<answer 1>
<answer 2>
<answer 3>
EOF

This requires that you know the exact answers beforehand.

Related Question