Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am using the line below in my script add-apt-repository ppa:webupd8team/java When it is run from the script I get a prompt to press [return] to confirm adding the source to the repositories

Can I automate that return?

Secondly, I am installing oracle-java7-installer and there is a license agreement that prompts for the user to: 1.. OK the License agreement 2.. select YES to Accept License Terms

Can I automate the OK and automate the keypad left & OK to Accept License Terms? This script is for testing locally and I do want the script to pause for these user inputs each time.

I have seen this method of piping YES to a command: yes | <command here>

I am hoping there is a similar method to automate these steps...

like image 541
linuxnoob Avatar asked Sep 12 '13 21:09

linuxnoob


1 Answers

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

The 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
like image 193
Ross Avatar answered Nov 02 '22 04:11

Ross