Simulating Enter in Bash Script on CentOS 6 Minimal

125 views Asked by At

Right now I am using:

echo -ne '\n' | alternatives --config java

For

Enter to keep the current selection, or type selection number:

I know there are probably many ways to do this. I am looking for the correct way to perform this action. I honestly don't even know if I'm doing it right.

1

There are 1 answers

0
Maciej Wawrzyńczuk On BEST ANSWER

Probably you could use something less interactive.

alternatives --set java /your/favorite/version

should work. Or you can use 'expect' command to emulate user input.