bash 命令:如何自动输入安装过程中稍后出现的菜单选项?

bash 命令:如何自动输入安装过程中稍后出现的菜单选项?

apt-get install -y python-catkin-toolsUbuntu 上安装“tzdata (2020f-0ubuntu0.18.04)”时,您必须输入地区时区数字 8 和城市时区数字 7。

我该如何运行apt-get install -y python-catkin-tools,以便稍后弹出的菜单选项在可以输入时首先获得 8,然后获得 7?我已用 ## 标记要输入的数字

apt-get install -y python-catkin-tools

...

Setting up tzdata (2020f-0ubuntu0.18.04) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
Configuring tzdata
------------------

Please select the geographic area in which you live. Subsequent configuration questions will narrow this down by presenting a list of cities, representing the time zones in which they are located.

  1. Africa  2. America  3. Antarctica  4. Australia  5. Arctic  6. Asia  7. Atlantic  8. Europe  9. Indian  10. Pacific  11. SystemV  12. US  13. Etc
Geographic area: ##8##

Please select the city or region corresponding to your time zone.

  1. Amsterdam  6. Belgrade    11. Budapest    [shortened...]

Time zone:


Time zone: ##7##

Current default time zone: 'Europe/Berlin'
Local time is now:      Wed Jan 20 22:42:43 CET 2021.
Universal Time is now:  Wed Jan 20 21:42:43 UTC 2021.
Run 'dpkg-reconfigure tzdata' if you wish to change it.

我需要它从 Dockerfile 自动运行,而无需用户在安装期间输入时区。我想知道如何将正确的时区作为安装命令的参数放在这里,或者作为一种简单的解决方法,如何强制它使用默认时区。

在最近的一次运行后,我发现在安装过程中从 Dockerfile 输入数字似乎也不起作用。这些输入不会触发任何事情。

[...]
Setting up tzdata (2021a-0ubuntu0.18.04) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Configuring tzdata
------------------

Please select the geographic area in which you live. Subsequent configuration
questions will narrow this down by presenting a list of cities, representing
the time zones in which they are located.

  1. Africa      4. Australia  7. Atlantic  10. Pacific  13. Etc
  2. America     5. Arctic     8. Europe    11. SystemV
  3. Antarctica  6. Asia       9. Indian    12. US
Geographic area: 8

7
^C

由于我认为该问题并非 apt-get 或操作系统所特有,因此我没有将其标记为此类问题。如果我在此处有误,请进行更改。

答案1

在构建 Dockerfile 时,这对我来说不起作用:

(您仍然可以尝试,也可以使用外部链接)

如果您想浏览工作菜单并在菜单中手动输入您选择的值,您需要一个“控制台设置”(例如带有 的 gnome-terminal apt-get install -y gnome-terminal)才能拥有终端对话框。但我无法让它运行,可能ssh需要它,请参阅“无法初始化前端:使用 ssh 时对话框”的答案,这意味着在这种情况下激活终端(TERM)并使用“对话框”作为前端:

TERM=$TERM DEBIAN_FRONTEND=dialog apt-get install -y python-catkin-tools


在构建 Dockerfile 时,这对我有用:

如果您确实想输入菜单点,以下解决方法将无济于事。如果您对默认设置感到满意,在本例中为 zone/city = "etc./etc.",解决方案如下,取自在docker下安装时可以回答对话框问题吗?

  1. 改成apt-get install -y python-catkin-tools

    DEBIAN_FRONTEND=noninteractive apt-get install -y python-catkin-tools
    

抑制紧随其后的命令的菜单。

  1. 您还可以在 Dockerfile 安装期间隐藏任何​​菜单,然后将其放在开头:

    ARG DEBIAN_FRONTEND=noninteractive
    
  2. 请不要输入此项,因为即使在图像中它也将被保留为设置:

    ENV DEBIAN_FRONTEND=noninteractive
    

最好使用“1.”,因为您可能不想抑制出现的每个其他菜单点。

相关内容