Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
share|improve this question
add comment

migrated from stackoverflow.com Jun 11 '12 at 7:34

This question came from our site for professional and enthusiast programmers.

3 Answers

up vote 3 down vote accepted

You want the tool called expect.

share|improve this answer
add comment

In some cases, you can use yes.

share|improve this answer
add comment

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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