linux poison RSS
linux poison Email

Display Dialog boxes from shell scripts - Whiptail

whiptail is a lightweight replacement for dialog, to provide dialog boxes for shell scripts. It is built on the newt windowing library rather than the ncurses library, allowing it to be smaller in embedded environments such as installers, rescue disks, etc.

Currently, these types of dialog boxes are implemented:
yes/no box, menu box, input box, message box, text box, info box, checklist  box,  radiolist box gauge box, and password box.

whiptail is designed to be drop-in compatible with dialog, but has less features: some dialog boxes are not implemented, such as tailbox, timebox, calendarbox, etc.

Whiptail Installation:
Open the terminal and type following command to install whiptail:
sudo apt-get install whiptail

Using Whiptail:
Below is a simple bash script which demonstrates the usage of showing the dialog box using whiptail:

whiptail --inputbox "Please enter you name ..." 10 50 2>$result
echo "Ok, your name is $(cat $result)"
rm $result

Look at the whiptail man pages for creating other different types of dialog boxes

Below is simple bash script which creates the progress bar using whiptail


    for ((i = 0 ; i <= 100 ; i+=30)); do
        sleep 1
        echo $i
} | whiptail --gauge "Please wait" 5 50 0


Post a Comment

Related Posts with Thumbnails