Need help with expect script to install Tripwire

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I want to write an expect script to install and configure Tripwire (open source) on ubuntu (Package name is 'tripwire'). This package presents dialog boxes created with whiptail to configure it.



This is the expect script named tripwire.exp that I wrote



#!/usr/bin/expect

spawn apt-get install -y tripwire

expect -exact "Do you wish to create/use your site key passphrase during installation?"
send ^[[C
send -- "/r"

expect -exact "Do you wish to create/use your local key passphrase during installation?"
send ^[[C
send -- "/r"

expect -exact "Tripwire has been installed"
send -- "/r"


When I execute this using sudo expect tripwire.exp, I am presented with the first whiptail dialog box in the tripwire configuration. After a few seconds my terminal prompt appears as <ubuntu@Tripwire2:~$ in the middle of the terminal with < highlighted in red. However there are no errors. But when I check if the package has been installed, it hasn't.



I then executed it in debug mode with sudo expect -d tripwire.exp and this is the output I got



spawn apt-get install -y tripwire^M
^MReading package lists... 0%^M^MReading package lists... 100%^M^MReading package lists... Done^M^M
^MBuilding dependency tree... 0%^M^MBuilding dependency tree... 0%^M^MBuilding dependency tree... 50%^M^MBuilding dependency tree... 50%^M^MBuilding dependency tree ^M^M
^MReading state information... 0%^M^MReading state information... 1%^M^MReading state information... Done^M^M
The following NEW packages will be installed:^M
tripwire^M
0 upgraded, 1 newly installed, 0 to remove and 18 not upgraded.^M
Need to get 0 B/1,474 kB of archives.^M
After this operation, 11.1 MB of additional disk space will be used.^M
Preconfiguring packages ...^M
^[[?1049h^[[1;48r^[[4l^[[?25l^[(B^[[m^[[37m^[[40m^[[1;48r^[[H^[[2J^[[1;1H^[[97m^[[45m^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K^[[1;1H^[[37mPackage configuration^[[13;2H^[[30m^[[47m┌────────────────────────┤ ^[[31mTripwire Configuration^[[30m ├─────────────────────────┐^[[14;2H│ │^[[97m^[[40m ^[[15;2H^[[30m^[[47m│ Tripwire uses a pair of keys to sign various files, thus ensuring their │^[[97m^[[40m ^[[16;2H^[[30m^[[47m│ unaltered state. By accepting here, you will be prompted for the │^[[97m^[[40m ^[[17;2H^[[30m^[[47m│ passphrase for the first of those keys, the site key, during the │^[[97m^[[40m ^[[18;2H^[[30m^[[47m│ installation. You are also agreeing to create a site key if one doesn't │^[[97m^[[40m ^[[19;2H^[[30m^[[47m│ exist already. Tripwire uses the site key to sign files that may be │^[[97m^[[40m ^[[20;2H^[[30m^[[47m│ common to multiple systems, e.g. the configuration & policy files. See │^[[97m^[[40m ^[[21;2H^[[30m^[[47m│ twfiles(5) for more information. │^[[97m^[[40m ^[[22;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[23;2H^[[30m^[[47m│ Unfortunately, due to the Debian installation process, there is a period │^[[97m^[[40m ^[[24;2H^[[30m^[[47m│ of time where this passphrase exists in a unencrypted format. Were an │^[[97m^[[40m ^[[25;2H^[[30m^[[47m│ attacker to have access to your machine during this period, he could │^[[97m^[[40m ^[[26;2H^[[30m^[[47m│ possibly retrieve your passphrase and use it at some later point. │^[[97m^[[40m ^[[27;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[28;2H^[[30m^[[47m│ If you would rather not have this exposure, decline here. You will then │^[[97m^[[40m ^[[29;2H^[[30m^[[47m│ need to create a site key, configuration file & policy file by hand. │^[[97m^[[40m ^[[30;2H^[[30m^[[47m│ See twadmin(8) for more information. │^[[97m^[[40m ^[[31;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[32;2H^[[30m^[[47m│ Do you wish to create/use your site key passphrase during installation? │^[[97m^[[40m ^[[33;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[34;2H^[[30m^[[47m│ ^[[37m^[[41m<Yes>^[[30m^[[47m <No> │^[[97m^[[40m ^[[35;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[36;2H^[[30m^[[47m└───────────────────────────────────────────────────────────────────────────┘^[[97m^[[40m ^[[37;3H ^[[34;24H


What should I do to get my script working?










share|improve this question

















  • 2




    You should consider preseeding the desired responses and setting DEBIAN_FRONTEND=noninteractive, or at least setting DEBIAN_FRONTEND=readline so that you can avoid having to interact with dialogs at all. See for example How can I install apt packages non-interactively?
    – steeldriver
    Sep 25 '17 at 10:51














up vote
0
down vote

favorite












I want to write an expect script to install and configure Tripwire (open source) on ubuntu (Package name is 'tripwire'). This package presents dialog boxes created with whiptail to configure it.



This is the expect script named tripwire.exp that I wrote



#!/usr/bin/expect

spawn apt-get install -y tripwire

expect -exact "Do you wish to create/use your site key passphrase during installation?"
send ^[[C
send -- "/r"

expect -exact "Do you wish to create/use your local key passphrase during installation?"
send ^[[C
send -- "/r"

expect -exact "Tripwire has been installed"
send -- "/r"


When I execute this using sudo expect tripwire.exp, I am presented with the first whiptail dialog box in the tripwire configuration. After a few seconds my terminal prompt appears as <ubuntu@Tripwire2:~$ in the middle of the terminal with < highlighted in red. However there are no errors. But when I check if the package has been installed, it hasn't.



I then executed it in debug mode with sudo expect -d tripwire.exp and this is the output I got



spawn apt-get install -y tripwire^M
^MReading package lists... 0%^M^MReading package lists... 100%^M^MReading package lists... Done^M^M
^MBuilding dependency tree... 0%^M^MBuilding dependency tree... 0%^M^MBuilding dependency tree... 50%^M^MBuilding dependency tree... 50%^M^MBuilding dependency tree ^M^M
^MReading state information... 0%^M^MReading state information... 1%^M^MReading state information... Done^M^M
The following NEW packages will be installed:^M
tripwire^M
0 upgraded, 1 newly installed, 0 to remove and 18 not upgraded.^M
Need to get 0 B/1,474 kB of archives.^M
After this operation, 11.1 MB of additional disk space will be used.^M
Preconfiguring packages ...^M
^[[?1049h^[[1;48r^[[4l^[[?25l^[(B^[[m^[[37m^[[40m^[[1;48r^[[H^[[2J^[[1;1H^[[97m^[[45m^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K^[[1;1H^[[37mPackage configuration^[[13;2H^[[30m^[[47m┌────────────────────────┤ ^[[31mTripwire Configuration^[[30m ├─────────────────────────┐^[[14;2H│ │^[[97m^[[40m ^[[15;2H^[[30m^[[47m│ Tripwire uses a pair of keys to sign various files, thus ensuring their │^[[97m^[[40m ^[[16;2H^[[30m^[[47m│ unaltered state. By accepting here, you will be prompted for the │^[[97m^[[40m ^[[17;2H^[[30m^[[47m│ passphrase for the first of those keys, the site key, during the │^[[97m^[[40m ^[[18;2H^[[30m^[[47m│ installation. You are also agreeing to create a site key if one doesn't │^[[97m^[[40m ^[[19;2H^[[30m^[[47m│ exist already. Tripwire uses the site key to sign files that may be │^[[97m^[[40m ^[[20;2H^[[30m^[[47m│ common to multiple systems, e.g. the configuration & policy files. See │^[[97m^[[40m ^[[21;2H^[[30m^[[47m│ twfiles(5) for more information. │^[[97m^[[40m ^[[22;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[23;2H^[[30m^[[47m│ Unfortunately, due to the Debian installation process, there is a period │^[[97m^[[40m ^[[24;2H^[[30m^[[47m│ of time where this passphrase exists in a unencrypted format. Were an │^[[97m^[[40m ^[[25;2H^[[30m^[[47m│ attacker to have access to your machine during this period, he could │^[[97m^[[40m ^[[26;2H^[[30m^[[47m│ possibly retrieve your passphrase and use it at some later point. │^[[97m^[[40m ^[[27;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[28;2H^[[30m^[[47m│ If you would rather not have this exposure, decline here. You will then │^[[97m^[[40m ^[[29;2H^[[30m^[[47m│ need to create a site key, configuration file & policy file by hand. │^[[97m^[[40m ^[[30;2H^[[30m^[[47m│ See twadmin(8) for more information. │^[[97m^[[40m ^[[31;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[32;2H^[[30m^[[47m│ Do you wish to create/use your site key passphrase during installation? │^[[97m^[[40m ^[[33;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[34;2H^[[30m^[[47m│ ^[[37m^[[41m<Yes>^[[30m^[[47m <No> │^[[97m^[[40m ^[[35;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[36;2H^[[30m^[[47m└───────────────────────────────────────────────────────────────────────────┘^[[97m^[[40m ^[[37;3H ^[[34;24H


What should I do to get my script working?










share|improve this question

















  • 2




    You should consider preseeding the desired responses and setting DEBIAN_FRONTEND=noninteractive, or at least setting DEBIAN_FRONTEND=readline so that you can avoid having to interact with dialogs at all. See for example How can I install apt packages non-interactively?
    – steeldriver
    Sep 25 '17 at 10:51












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I want to write an expect script to install and configure Tripwire (open source) on ubuntu (Package name is 'tripwire'). This package presents dialog boxes created with whiptail to configure it.



This is the expect script named tripwire.exp that I wrote



#!/usr/bin/expect

spawn apt-get install -y tripwire

expect -exact "Do you wish to create/use your site key passphrase during installation?"
send ^[[C
send -- "/r"

expect -exact "Do you wish to create/use your local key passphrase during installation?"
send ^[[C
send -- "/r"

expect -exact "Tripwire has been installed"
send -- "/r"


When I execute this using sudo expect tripwire.exp, I am presented with the first whiptail dialog box in the tripwire configuration. After a few seconds my terminal prompt appears as <ubuntu@Tripwire2:~$ in the middle of the terminal with < highlighted in red. However there are no errors. But when I check if the package has been installed, it hasn't.



I then executed it in debug mode with sudo expect -d tripwire.exp and this is the output I got



spawn apt-get install -y tripwire^M
^MReading package lists... 0%^M^MReading package lists... 100%^M^MReading package lists... Done^M^M
^MBuilding dependency tree... 0%^M^MBuilding dependency tree... 0%^M^MBuilding dependency tree... 50%^M^MBuilding dependency tree... 50%^M^MBuilding dependency tree ^M^M
^MReading state information... 0%^M^MReading state information... 1%^M^MReading state information... Done^M^M
The following NEW packages will be installed:^M
tripwire^M
0 upgraded, 1 newly installed, 0 to remove and 18 not upgraded.^M
Need to get 0 B/1,474 kB of archives.^M
After this operation, 11.1 MB of additional disk space will be used.^M
Preconfiguring packages ...^M
^[[?1049h^[[1;48r^[[4l^[[?25l^[(B^[[m^[[37m^[[40m^[[1;48r^[[H^[[2J^[[1;1H^[[97m^[[45m^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K^[[1;1H^[[37mPackage configuration^[[13;2H^[[30m^[[47m┌────────────────────────┤ ^[[31mTripwire Configuration^[[30m ├─────────────────────────┐^[[14;2H│ │^[[97m^[[40m ^[[15;2H^[[30m^[[47m│ Tripwire uses a pair of keys to sign various files, thus ensuring their │^[[97m^[[40m ^[[16;2H^[[30m^[[47m│ unaltered state. By accepting here, you will be prompted for the │^[[97m^[[40m ^[[17;2H^[[30m^[[47m│ passphrase for the first of those keys, the site key, during the │^[[97m^[[40m ^[[18;2H^[[30m^[[47m│ installation. You are also agreeing to create a site key if one doesn't │^[[97m^[[40m ^[[19;2H^[[30m^[[47m│ exist already. Tripwire uses the site key to sign files that may be │^[[97m^[[40m ^[[20;2H^[[30m^[[47m│ common to multiple systems, e.g. the configuration & policy files. See │^[[97m^[[40m ^[[21;2H^[[30m^[[47m│ twfiles(5) for more information. │^[[97m^[[40m ^[[22;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[23;2H^[[30m^[[47m│ Unfortunately, due to the Debian installation process, there is a period │^[[97m^[[40m ^[[24;2H^[[30m^[[47m│ of time where this passphrase exists in a unencrypted format. Were an │^[[97m^[[40m ^[[25;2H^[[30m^[[47m│ attacker to have access to your machine during this period, he could │^[[97m^[[40m ^[[26;2H^[[30m^[[47m│ possibly retrieve your passphrase and use it at some later point. │^[[97m^[[40m ^[[27;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[28;2H^[[30m^[[47m│ If you would rather not have this exposure, decline here. You will then │^[[97m^[[40m ^[[29;2H^[[30m^[[47m│ need to create a site key, configuration file & policy file by hand. │^[[97m^[[40m ^[[30;2H^[[30m^[[47m│ See twadmin(8) for more information. │^[[97m^[[40m ^[[31;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[32;2H^[[30m^[[47m│ Do you wish to create/use your site key passphrase during installation? │^[[97m^[[40m ^[[33;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[34;2H^[[30m^[[47m│ ^[[37m^[[41m<Yes>^[[30m^[[47m <No> │^[[97m^[[40m ^[[35;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[36;2H^[[30m^[[47m└───────────────────────────────────────────────────────────────────────────┘^[[97m^[[40m ^[[37;3H ^[[34;24H


What should I do to get my script working?










share|improve this question













I want to write an expect script to install and configure Tripwire (open source) on ubuntu (Package name is 'tripwire'). This package presents dialog boxes created with whiptail to configure it.



This is the expect script named tripwire.exp that I wrote



#!/usr/bin/expect

spawn apt-get install -y tripwire

expect -exact "Do you wish to create/use your site key passphrase during installation?"
send ^[[C
send -- "/r"

expect -exact "Do you wish to create/use your local key passphrase during installation?"
send ^[[C
send -- "/r"

expect -exact "Tripwire has been installed"
send -- "/r"


When I execute this using sudo expect tripwire.exp, I am presented with the first whiptail dialog box in the tripwire configuration. After a few seconds my terminal prompt appears as <ubuntu@Tripwire2:~$ in the middle of the terminal with < highlighted in red. However there are no errors. But when I check if the package has been installed, it hasn't.



I then executed it in debug mode with sudo expect -d tripwire.exp and this is the output I got



spawn apt-get install -y tripwire^M
^MReading package lists... 0%^M^MReading package lists... 100%^M^MReading package lists... Done^M^M
^MBuilding dependency tree... 0%^M^MBuilding dependency tree... 0%^M^MBuilding dependency tree... 50%^M^MBuilding dependency tree... 50%^M^MBuilding dependency tree ^M^M
^MReading state information... 0%^M^MReading state information... 1%^M^MReading state information... Done^M^M
The following NEW packages will be installed:^M
tripwire^M
0 upgraded, 1 newly installed, 0 to remove and 18 not upgraded.^M
Need to get 0 B/1,474 kB of archives.^M
After this operation, 11.1 MB of additional disk space will be used.^M
Preconfiguring packages ...^M
^[[?1049h^[[1;48r^[[4l^[[?25l^[(B^[[m^[[37m^[[40m^[[1;48r^[[H^[[2J^[[1;1H^[[97m^[[45m^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K
^[[K^[[1;1H^[[37mPackage configuration^[[13;2H^[[30m^[[47m┌────────────────────────┤ ^[[31mTripwire Configuration^[[30m ├─────────────────────────┐^[[14;2H│ │^[[97m^[[40m ^[[15;2H^[[30m^[[47m│ Tripwire uses a pair of keys to sign various files, thus ensuring their │^[[97m^[[40m ^[[16;2H^[[30m^[[47m│ unaltered state. By accepting here, you will be prompted for the │^[[97m^[[40m ^[[17;2H^[[30m^[[47m│ passphrase for the first of those keys, the site key, during the │^[[97m^[[40m ^[[18;2H^[[30m^[[47m│ installation. You are also agreeing to create a site key if one doesn't │^[[97m^[[40m ^[[19;2H^[[30m^[[47m│ exist already. Tripwire uses the site key to sign files that may be │^[[97m^[[40m ^[[20;2H^[[30m^[[47m│ common to multiple systems, e.g. the configuration & policy files. See │^[[97m^[[40m ^[[21;2H^[[30m^[[47m│ twfiles(5) for more information. │^[[97m^[[40m ^[[22;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[23;2H^[[30m^[[47m│ Unfortunately, due to the Debian installation process, there is a period │^[[97m^[[40m ^[[24;2H^[[30m^[[47m│ of time where this passphrase exists in a unencrypted format. Were an │^[[97m^[[40m ^[[25;2H^[[30m^[[47m│ attacker to have access to your machine during this period, he could │^[[97m^[[40m ^[[26;2H^[[30m^[[47m│ possibly retrieve your passphrase and use it at some later point. │^[[97m^[[40m ^[[27;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[28;2H^[[30m^[[47m│ If you would rather not have this exposure, decline here. You will then │^[[97m^[[40m ^[[29;2H^[[30m^[[47m│ need to create a site key, configuration file & policy file by hand. │^[[97m^[[40m ^[[30;2H^[[30m^[[47m│ See twadmin(8) for more information. │^[[97m^[[40m ^[[31;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[32;2H^[[30m^[[47m│ Do you wish to create/use your site key passphrase during installation? │^[[97m^[[40m ^[[33;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[34;2H^[[30m^[[47m│ ^[[37m^[[41m<Yes>^[[30m^[[47m <No> │^[[97m^[[40m ^[[35;2H^[[30m^[[47m│ │^[[97m^[[40m ^[[36;2H^[[30m^[[47m└───────────────────────────────────────────────────────────────────────────┘^[[97m^[[40m ^[[37;3H ^[[34;24H


What should I do to get my script working?







scripting expect whiptail tripwire






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 25 '17 at 9:10









Nilushan

379




379







  • 2




    You should consider preseeding the desired responses and setting DEBIAN_FRONTEND=noninteractive, or at least setting DEBIAN_FRONTEND=readline so that you can avoid having to interact with dialogs at all. See for example How can I install apt packages non-interactively?
    – steeldriver
    Sep 25 '17 at 10:51












  • 2




    You should consider preseeding the desired responses and setting DEBIAN_FRONTEND=noninteractive, or at least setting DEBIAN_FRONTEND=readline so that you can avoid having to interact with dialogs at all. See for example How can I install apt packages non-interactively?
    – steeldriver
    Sep 25 '17 at 10:51







2




2




You should consider preseeding the desired responses and setting DEBIAN_FRONTEND=noninteractive, or at least setting DEBIAN_FRONTEND=readline so that you can avoid having to interact with dialogs at all. See for example How can I install apt packages non-interactively?
– steeldriver
Sep 25 '17 at 10:51




You should consider preseeding the desired responses and setting DEBIAN_FRONTEND=noninteractive, or at least setting DEBIAN_FRONTEND=readline so that you can avoid having to interact with dialogs at all. See for example How can I install apt packages non-interactively?
– steeldriver
Sep 25 '17 at 10:51















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394281%2fneed-help-with-expect-script-to-install-tripwire%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394281%2fneed-help-with-expect-script-to-install-tripwire%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay