You may not be able to install Expect on the target server. This is often the case when someone writes, say, Jenkins' work.
If so, I would like to consider something like the answer to the following question on askubuntu.com:
https://askubuntu.com/questions/338857/automatically-enter-input-in-command-line
printf 'y\nyes\nno\nmaybe\n' | ./script_that_needs_user_input
Note that in some rare cases, the command does not require the user to press enter after the character. in this case, leave a newline:
printf 'yyy' | ./script_that_needs_user_input
For completeness, you can also use the document here:
./script_that_needs_user_input << EOF y y y EOF
Or, if your shell supports the line here:
./script <<< "y y y "
Or you can create a file with one input per line:
./script < inputfile
Again, all the credit for this answer belongs to the author of the answer on askubuntu.com , Lesmana.
Nathan Basanese Dec 09 '15 at 10:44 2015-12-09 10:44
source share