user3086559
user3086559

Reputation: 39

Multiple inputs for shell

Got struck while trying to write a shell script which should automatically give input.

While running a script for eg: adpatch.sh

It Prompts for Multiple inputs like:

Do you currently have files used for installing or upgrading the database
installed in this APPL_TOP [YES] ? need to give input here


Do you currently have Java and HTML files for HTML-based functionality
installed in this APPL_TOP [YES] ? need to give input here


Do you currently have Oracle Applications forms files installed
in this APPL_TOP [YES] ? need to give input here


Do you currently have concurrent program files installed
in this APPL_TOP [YES] ? need to give input here

so without using Command Line Arguments, is there any other way of giving the input automatically? Thanks in Advance.

Upvotes: 0

Views: 523

Answers (1)

meganerd
meganerd

Reputation: 11

I believe that expect is what you want. You may need to install it first ("apt-get install expect" from Debian/Ubuntu based Linux distros).

Expect has the advantage of pairing responses with specific questions, instead of just blindly replying with "YES".

From the man page:

In general, Expect is useful for running any program which requires interaction between the program and the user. All that is necessary is that the interaction can be characterized programmatically. Expect can also give the user back control (without halting the program being controlled) if desired. Similarly, the user can return control to the script at any time".

Upvotes: 1

Related Questions