Is there a way to automate the return key after the linux script command?

I use the line below in the add-apt-repository ppa:webupd8team/java When it starts from a script, I get a prompt to press [return] to confirm adding the source to the repository

Can I automate this return?

Secondly, I install oracle-java7-installer, and there is a license agreement in which the user is offered: 1 .. OK license agreement 2. Select YES to accept the license terms.

Is it possible to automate OK and automate the keyboard to the left and OK to accept the license terms? This script is for local testing, and I want the script to stop for these user inputs every time.

I saw this method of connecting YES to the command: yes | <command here> yes | <command here>

I hope there is a similar method to automate these steps ...

+7
linux shell return key
source share
2 answers

The echo command will create a new line!

0
source share

For add-apt-repository you can use the -y flag to skip the yes / no prompt.

Oracle Java one is a little more complicated, but this will do what you want:

 echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections # Install required packages sudo apt-get install oracle-java7-installer -y 
+2
source share

All Articles