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.