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

查看:218
本文介绍了在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:

export DEBIAN_FRONTEND=noninteractive

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天全站免登陆