7

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 ?

Ruslan Osmanov
  • 20,486
  • 7
  • 46
  • 60

1 Answers1

5

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.

Aserre
  • 4,916
  • 5
  • 33
  • 56
  • Thanks for the response, but your script doesn't seem to run, it is stuck at zero percentage for 5-6 seconds and then exits. – Anuj Shrivastava Dec 07 '16 at 05:43
  • what OS/version of whiptail are you using ? copying & pasting this code snippet on my machine works perfectly (whiptail 0.52.18 running on wsl - Ubuntu 16.04) – Aserre Dec 07 '16 at 09:13
  • I am running it in RHEL 6 with whiptail version : whiptail (newt): 0.52.11 then it stucks whereas i verified in RHEL 7 with whiptail version whiptail (newt): 0.52.15, there it works perfectly. But i need it for RHEL 6. – Anuj Shrivastava Dec 07 '16 at 11:17