Linux下利用python实现tripwire的自动安装

2024-04-24 05:12:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试通过apt-get-through Python的subprocess模块在ubuntulinux中自动安装tripwire。我遇到的问题是在安装过程中,Tripwire提示我进行Postfix邮件配置,设置站点.key以及本地.key通过安装apt-get后出现的不同配置页面(见附图)。在

如何使用子流程模块与这些页面交互?在

from subprocess import *
p=Popen("apt-get install tripwire",stdout=PIPE,stdin=PIPE,stderr=PIPE,shell=True)
p.communicate(input="Y\n") # Y = Yes to confirm installation of the package through apt-get

我试图使用“stdin=PIPE”,但是在与这些终端页面交互时,有几个挑战:

  1. 这些页面将在下载包后出现,并且 所以我必须为 要显示的页面

  2. 另外,我需要实现上下箭头键来选择各种选项。

谢谢

约翰

enter image description here


Tags: 模块keyget过程stdin邮件apt页面
1条回答
网友
1楼 · 发布于 2024-04-24 05:12:18

在启用自动确认和安静模式的情况下启动安装并设置this flag

export DEBIAN_FRONTEND=noninteractive

apt-get install -y -q tripwire

这样您就不需要与安装后配置进行通信。 也可以使用-c传递预存在的config文件(或使用-o指定配置选项)。在

我可能会尝试:

from subprocess import call
p = call(["apt-get", "install", "-y", "-q", "-c", "config.cfg", "tripwire", shell=False])

相关问题 更多 >