• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

whiptail Command Examples in Linux

by Deepika

The “whiptail” command is a Unix/Linux utility that allows shell scripts to display text-based dialog boxes for user interaction. It is commonly used to create interactive scripts that can prompt the user for input or display messages in a graphical format.

The “whiptail” command is based on the “dialog” command, which provides similar functionality but with a more traditional command-line interface. The advantage of “whiptail” is that it provides a more user-friendly interface that is easier to use and understand.

“Whiptail” can display a wide variety of dialog boxes, including message boxes, input boxes, password boxes, and menu boxes. These dialog boxes can be customized with different colors, fonts, and sizes to make them more visually appealing.

For example, a shell script could use “whiptail” to display a message box to the user when an error occurs, asking them to try again or exit the script. Or, it could use an input box to prompt the user for a password before performing a sensitive operation.

The “whiptail” command is particularly useful for creating simple and lightweight graphical interfaces for scripts, especially those that run on headless servers or in remote environments where a graphical user interface is not available. It can also be used to create menu-driven scripts that are easier for users to navigate and understand.

whiptail Command Examples

1. Display a simple message:

# whiptail --title "title" --msgbox "message" height_in_chars width_in_chars

2. Display a boolean choice, returning the result through the exit code:

# whiptail --title "title" --yesno "message" height_in_chars width_in_chars

3. Customise the text on the yes / no buttons:

# whiptail --title "title" --yes-button "text" --no-button "text" --yesno "message" height_in_chars width_in_chars

4. Display a text input box:

# result_variable_name="$(whiptail --title "title" --inputbox "message" height_in_chars width_in_chars default_text 3>&1 1>&2 2>&3)"

5. Display a password input box:

# result_variable_name="$(whiptail --title "title" --passwordbox "message" height_in_chars width_in_chars 3>&1 1>&2 2>&3)"

6. Display a multiple-choice menu:

# result_variable_name=$(whiptail --title "title" --menu "message" height_in_chars width_in_chars menu_display_height "value_1" "display_text_1" "value_n" "display_text_n" ..... 3>&1 1>&2 2>&3)

Summary

Overall, “whiptail” is a versatile and powerful utility that can greatly enhance the user experience of shell scripts by providing a simple and intuitive graphical interface.

Filed Under: Linux

Some more articles you might also be interested in …

  1. foreman Command Examples in Linux
  2. rpmbuild : command not found
  3. fsck: command not found
  4. ip: command not found
  5. How to Remove/Delete All Packages from Channel(s) in SpaceWalk
  6. apktool – Reverse engineer APK files (Command Examples)
  7. How To Migrate Existing Iptables rules to Nftables In CentOS/RHEL 8
  8. journalctl: command not found
  9. firewall-cmd: command not found
  10. Most commonly performed operations in Yocto

You May Also Like

Primary Sidebar

Recent Posts

  • aws ec2: CLI for AWS EC2 (Command Examples)
  • aws cur – Create, query, and delete AWS usage report definitions (Command Examples)
  • aws configure – Manage configuration for the AWS CLI (Command Examples)
  • aws cognito-idp: Manage Amazon Cognito user pool and its users and groups using the CLI

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright