Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

For most packages that require a yes/no answer, this works fine for me:

sudo apt-get install -y ....

But if you require a package that makes you accept a license, how do you automatically agree to that?

For example, sun java:

sudo apt-get install -y sun-java6-bin sun-java6-jdk sun-java6-jre sun-java6-plugin

This requires me to select OK, and then yes.

share|improve this question
1  
Just some info: the sun flavored java has just been removed from debian. So you are running an unsupported program and you will not get security updates. (This also applies to ubuntu because of license restrictions). sylvestre.ledru.info/blog/sylvestre/2011/08/26/… You should take a look at openjdk. –  cstamas Nov 1 '11 at 9:23

1 Answer 1

There are some ways to do this:

  1. Pre-answer with debconf by executing the following command before installing:

    echo sun-java6-jdk shared/accepted-sun-dlj-v1-1 select true | \
        /usr/bin/debconf-set-selections
    
  2. Use expect:

    #!/usr/bin/expect -f
    sudo apt-get -y install sun-java6-jre
    expect "[y/n]"
    sleep 1
    send -- "yes\r"
    
share|improve this answer
    
so would you put that echo line after the apt-get install line? –  codecompleting Nov 1 '11 at 20:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.