4

I am writing a bash script that, amongst other things, installs some software. One of the installers I run requires answering some questions. For example:

Is the default install folder ok (yes/no)?
What is the email address you would like to use?

The installer does not provide an option to script responses. Is there a way to identify these prompts when running the installer from a bash script, and automatically providing a response? For example:

Is the default install folder ok (yes/no)? yes
What is the email address you would like to use? my@address.com
3

You want the tool called expect.

| improve this answer | |
1

In some cases, you can use yes.

| improve this answer | |
0

Did you try using a cast statement, like this?

#!/bin/bash

echo -n "Do you agree with this? [yes or no]: "
read yno
case $yno in

        [yY] | [yY][Ee][Ss] )
                echo "Agreed"
                ;;

        [nN] | [n|N][O|o] )
                echo "Not agreed, you can't proceed the installation";
                exit 1
                ;;
        *) echo "Invalid input"
            ;;
esac

$ ./yorno.sh
Do you agree with this? [yes or no]: YES
Agreed
| improve this answer | |

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.