有没有办法在 dpkg --configure 时传递要解析的参数请求用户输入?

有没有办法在 dpkg --configure 时传递要解析的参数请求用户输入?

我想dpkg --configure virtualbox-guest-x11从 shell 脚本中运行,以便它可以回答N以下问题。

$ dpkg --configure virtualbox-guest-x11
Setting up virtualbox-guest-x11 (4.1.12-dfsg-2ubuntu0.6) ...

Configuration file `/etc/X11/Xsession.d/98vboxadd-xclient'
 ==> File on system created by you or by a script.
 ==> File also in package provided by package maintainer.
   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.
*** 98vboxadd-xclient (Y/I/N/O/D/Z) [default=N] ?

有什么方法可以传递参数吗dpkg --configure?或者是否有某个文件可以在其中设置配置文件时应接受的默认参数virtualbox-guest-x11

答案1

是的:

yes N | dpkg --configure virtualbox-guest-x11

或者:

echo N | dpkg --configure virtualbox-guest-x11

或者:

dpkg --configure virtualbox-guest-x11 <<< "N"

或者,因为N在这种情况下是默认选项:

dpkg --configure --force-confdef virtualbox-guest-x11

相关内容