在 Linux 中通过 python 自动安装tripwire [英] Automating installation of tripwire via python in Linux

查看:20
本文介绍了在 Linux 中通过 python 自动安装tripwire的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 apt-get 在 Ubuntu Linux 中通过 Python 的子进程模块自动安装tripwire.我遇到的问题是,在安装过程中,Tripwire 提示我进行 Postfix 邮件配置,通过 apt-get 安装后出现的不同配置页面(见附图)设置 site.key 和 local.key.

I am trying to automate installation of tripwire via apt-get through Python's subprocess module in Ubuntu Linux. The problem I have is that during the installation process, Tripwire is prompting me for Postfix mail configuration, setting site.key and local.key through different set of configuration pages (see picture attached) which appear after apt-get has installed.

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

How can I use subprocess module to interact with these pages?

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",但是与这些终端页面交互存在一些挑战:

I tried to use "stdin=PIPE", but there are a couple of challenges with interacting with these terminal pages:

  1. 这些页面是在包下载完成后出现的配置,所以我必须实现某种延迟要出现的页面

  1. These pages appear after the package is downloaded and is being configured, so I have to implement some kind of delay for the page to appear

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

Also, I need to implement up and down arrow keys to choose the various options.

谢谢

约翰

推荐答案

启动安装并启用自动确认和安静模式并设置 这个标志:

Launch the install with auto-confirm and quiet mode enabled and set this flag:

导出 DEBIAN_FRONTEND=非交互式

apt-get install -y -q tripwire

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

This way you won't need to communicate with the post-install config. You can also pass along pre-exising config files with -c (or specify configuration options with -o).

我可能会尝试:

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

这篇关于在 Linux 中通过 python 自动安装tripwire的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆