0

I want to automate the installation of phpmyadmin using a shell script.

sudo apt install phpmyadmin is straight forward but I don't know how to automate the completion of this pop-up.

https://i.stack.imgur.com/DfKcZ.png

What I need to do, is to press space to select the desired option, then enter to confirm it.

Vassy
  • 11

1 Answers1

2

Install expect and write an expect script that answers the prompts. This will look something like this (warning - not tested in any way):

#!/usr/bin/expect
spawn sudo apt install phpmyadmin
expect "server to reconfigure automatically"
set send_slow {1 0.5}
send -s " \r"
wait

This will run sudo apt install phpmyadmin command, wait until a text server to reconfigure automatically appears on the screen (if you need to provide a password to sudo you should insert additional commands to handle this), then send two characters, space and Enter with 0.5 second delay between them, and finally wait until the command terminates.

Look here for more information about expect:

https://www.slashroot.in/expect-command-tutorial-linux-example-usage

http://tcl.tk/man/expect5.31/expect.1.html

raj
  • 10,353