Script to automatically install packages

I want to write a bash or perl script to install a number of packages on my debian based machine.

I want it to be something like :

aptitude install package1 
aptitude install package2

But, I do not know how how to automatically say "yes" through the script at the prompt to confirm you want to install that package. Can someone give me an example in perl and bash ?

gratz!


aptitude install -y package1 package2 package3


I guess this isn't really a script, but you could install puppet and use the package type. Then it will simply be a matter of creating a file with a bunch of package directives.

For example:

package { zsh:
        ensure => latest
}

package { vim-enhanced:
        ensure => latest,
        name => $operatingsystem ? {
                'centos' => 'vim-enhanced',
                'ubuntu' => 'vim',
        }

}

You could also use puppet to customize a bunch of other things like your shell, and your .rc files etc if you get in the mood to extend your scope. It might sound like overkill, but in the long run the little bit of extra effort will likely pay off.