How to by-pass user interactions in a script?

4

4

I am trying to automate the installation of a program through a shell script. There are a few steps which require user interaction from the command line (confirmation, yes/no, etc.). What is the best way to by-pass it? I know that one possibility is to use an expect script. Just wanted to know if there is a better/cleaner way to do this.

Vignesh

Posted 2012-01-19T11:11:36.837

Reputation: 43

Answers

8

If the interaction is simple, i.e. only reads from the standard input, you can just send the particular lines to the program's input:

( echo yes ; echo 1024; echo yes ) | install.sh

choroba

Posted 2012-01-19T11:11:36.837

Reputation: 14 741

3

If you want to do anything that doesn't just read from stdin (e.g. ftp login) you'll want to use expect.

Darth Egregious

Posted 2012-01-19T11:11:36.837

Reputation: 273