← 返回命令列表

Linux command

whiptail 命令

网络

复制后可按需替换文件名、目录或参数。

常用示例

Example

whiptail --title "[title]" --msgbox "[message]" [height] [width]

Example

whiptail --title "[title]" --yesno "[message]" [height] [width]

Customize

whiptail --title "[title]" --yes-button "[text]" --no-button "[text]" --yesno "[message]" [height] [width]

Example

result=$(whiptail --title "[title]" --inputbox "[message]" [height] [width] [default] 3>&1 1>&2 2>&3)

Example

result=$(whiptail --title "[title]" --passwordbox "[message]" [height] [width] 3>&1 1>&2 2>&3)

Example

result=$(whiptail --title "[title]" --menu "[message]" [height] [width] [menu_height] "val1" "text1" "val2" "text2" 3>&1 1>&2 2>&3)

Example

result=$(whiptail --title "[title]" --checklist "[message]" [height] [width] [list_height] "opt1" "text1" ON "opt2" "text2" OFF 3>&1 1>&2 2>&3)

Example

echo [50] | whiptail --title "[title]" --gauge "[message]" [height] [width] [0]

说明

whiptail displays text-based dialog boxes from shell scripts, providing a user-friendly interface for input and selection. It creates ncurses-based dialogs that work in terminal environments, supporting various dialog types including messages, input boxes, menus, and progress bars. Output from input dialogs goes to stderr, requiring file descriptor redirection (3>&1 1>&2 2>&3) to capture in shell variables. Exit codes indicate user choices (0 for OK/Yes, 1 for Cancel/No).

参数

--title _title_
Dialog title
--backtitle _text_
Background title
--msgbox _text_ _height_ _width_
Display message with OK button
--yesno _text_ _height_ _width_
Display yes/no dialog
--inputbox _text_ _height_ _width_ _init_
Text input dialog
--passwordbox _text_ _height_ _width_
Password input (hidden text)
--menu _text_ _height_ _width_ _menu-height_ _tag_ _item_...
Selection menu
--checklist _text_ _height_ _width_ _list-height_ _tag_ _item_ _status_...
Multiple choice checklist
--radiolist _text_ _height_ _width_ _list-height_ _tag_ _item_ _status_...
Radio button list
--gauge _text_ _height_ _width_ _percent_
Progress bar
--yes-button _text_
Custom yes button label
--no-button _text_
Custom no button label
--ok-button _text_
Custom OK button label
--cancel-button _text_
Custom cancel button label
--defaultno
Default to No in yes/no dialogs
--nocancel
Suppress the Cancel button
--separate-output
Output checklist results one per line
--scrolltext
Force display of a vertical scrollbar
--topleft
Place dialog in the top-left corner
--clear
Clear the screen on exit
--fullbuttons
Use full-width buttons instead of compact
--output-fd _FD_
Direct output to given file descriptor instead of stderr
--textbox _file_ _height_ _width_
Display contents of a file in a scrollable box
--infobox _text_ _height_ _width_
Display message without waiting for input

FAQ

What is the whiptail command used for?

whiptail displays text-based dialog boxes from shell scripts, providing a user-friendly interface for input and selection. It creates ncurses-based dialogs that work in terminal environments, supporting various dialog types including messages, input boxes, menus, and progress bars. Output from input dialogs goes to stderr, requiring file descriptor redirection (3>&1 1>&2 2>&3) to capture in shell variables. Exit codes indicate user choices (0 for OK/Yes, 1 for Cancel/No).

How do I run a basic whiptail example?

Run `whiptail --title "[title]" --msgbox "[message]" [height] [width]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --title _title_ do in whiptail?

Dialog title