Automating installation of tripwire via python in Linux

我们两清 提交于 2020-01-24 00:28:08

问题


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

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

  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

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

Thanks

John


回答1:


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

export DEBIAN_FRONTEND=noninteractive

apt-get install -y -q tripwire

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).

I would probably try:

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


来源:https://stackoverflow.com/questions/38419629/automating-installation-of-tripwire-via-python-in-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!