How to set a default option for dpkg --configure -a?

How can I send a command like following, but with default parameters (without user input). I want to use this in a shell script.

 dpkg --configure -a ...

 ==> Modified (by you or by a script) since installation.  ==> Package  
distributor has shipped an updated version.    What would you like to   
do about it ?  Your options are:  
Y or I  : install the package maintainer's version  
N or O  : keep your currently-installed version  
D     : show the differences between the versions  
Z     : start a shell to examine the situation  The default action is to keep your current version.  
*** CONFIGFILE (Y/I/N/O/D/Z) [default=N] ? ^C   

Solution 1:

That's a job for yes, if you always want the answer N:

yes N | dpkg --configure -a

Or Y (works without an argument):

yes | dpkg --configure -a

Or over the dpkg options, see dpkg --force-help:

[...]
[!] confnew            Always use the new config files, don't prompt
[!] confold            Always use the old config files, don't prompt
[!] confdef            Use the default option for new config files if one
                       is available, don't prompt. If no default can be found,
                       you will be prompted unless one of the confold or
                       confnew options is also given
[...]

Use then (for example):

dpkg --configure -a --force-confnew