Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display different messages on whiptail progress bar along with progress bar?

I am trying to use "whiptail" to display progress to users while removing some RPM's. Using

{
 echo 25
 yum remove package_name
 echo 50
 yum remove package_name
 echo 75 
 yum remove package_name
 echo 100
 sleep 1

} | whiptail --gauge "Removing RPM's" 6 60 0*

This is how it looks like

What i would like is to display message "Removing package_name" along with the progress bar, Like when redhat installs packages something like this How can i achieve that ?

like image 273
Anuj Shrivastava Avatar asked Dec 06 '16 07:12

Anuj Shrivastava


1 Answers

Whiptail uses a weird syntax to update the gauge text. Have a look at the following script :

#!/bin/bash
{
    sleep 0.5
    echo -e "XXX\n0\nyum remove package_0... \nXXX"
    sleep 2
    echo -e "XXX\n25\nyum remove package_0... Done.\nXXX"
    sleep 0.5

    echo -e "XXX\n25\nyum remove package_1... \nXXX"
    sleep 2
    echo -e "XXX\n50\nyum remove package_1... Done.\nXXX"
    sleep 0.5

    echo -e "XXX\n50\nyum remove package_2... \nXXX"
    sleep 2
    echo -e "XXX\n75\nyum remove package_2... Done.\nXXX"
    sleep 0.5

    echo -e "XXX\n75\nyum remove package_3... \nXXX"
    sleep 2
    echo -e "XXX\n100\nyum remove package_3... Done.\nXXX"
    sleep 1
} |whiptail --title "Yum Removal" --gauge "Please wait while installing" 6 60 0

Here, the key part is echo -n "XXX\n<new percent>\n<new_gauge_text>\nXXX". The XXX string is used by whiptail to indicate modifications to the display.

like image 72
Aserre Avatar answered Oct 25 '22 23:10

Aserre