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
  • 1
  • Instead of trying to interact with the dialog, consider pre-seeding your choice using `debconf-set-selections` - see for example [How can I prevent apt-get/aptitude from showing dialogs during installation?](https://askubuntu.com/questions/339790/how-can-i-prevent-apt-get-aptitude-from-showing-dialogs-during-installation) and [How can I install apt packages non-interactively?](https://askubuntu.com/questions/556385/how-can-i-install-apt-packages-non-interactively) – steeldriver Apr 30 '23 at 23:59

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
  • 9,367
  • 2
  • 16
  • 42