Linux command
dialog 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Example
dialog --msgbox "[Message]" [height] [width]
Example
dialog --inputbox "[Enter text:]" 8 40 2>[output.txt]
Example
dialog --yesno "[Continue?]" 7 40
Example
dialog --menu "[Choose one:]" 15 40 4 1 "[Option A]" 2 "[Option B]" 3 "[Option C]" 2>[output.txt]
Example
dialog --checklist "[Select items:]" 15 40 4 1 "[Item A]" on 2 "[Item B]" off 3 "[Item C]" on 2>[output.txt]
Example
dialog --gauge "[Installing...]" 7 40 0
Example
dialog --passwordbox "[Enter password:]" 8 40 2>[output.txt]
说明
dialog displays dialog boxes from shell scripts, providing a user-friendly text-based interface for interactive scripts. It supports various widget types including message boxes, input boxes, menus, checklists, radio lists, progress bars, and file selection dialogs. The program uses the ncurses library to create pseudo-graphical interfaces in text terminals. This enables shell scripts to present professional-looking user interfaces without requiring a graphical environment. Output is written to stderr (or a specified file), while exit status indicates which button was pressed (0 for OK/Yes, 1 for Cancel/No, 255 for ESC). This design allows scripts to capture both user selections and continue using stdout for other purposes. dialog is widely used in system administration scripts, installation programs, and configuration utilities.
参数
- --msgbox _text_ _height_ _width_
- Display message with OK button
- --yesno _text_ _height_ _width_
- Yes/No question dialog
- --inputbox _text_ _height_ _width_ _init_
- Text input dialog
- --menu _text_ _height_ _width_ _menu-height_ _tag_ _item_...
- Menu selection
- --checklist _text_ _height_ _width_ _list-height_ _tag_ _item_ _status_...
- Checkbox selection
- --radiolist _text_ _height_ _width_ _list-height_ _tag_ _item_ _status_...
- Radio button selection (single choice)
- --gauge _text_ _height_ _width_ _percent_
- Progress bar display
- --passwordbox _text_ _height_ _width_
- Password input (hidden characters)
- --fselect _filepath_ _height_ _width_
- File selection dialog
- --calendar _text_ _height_ _width_ _day_ _month_ _year_
- Calendar date selection
- --title _title_
- Set dialog title
- --backtitle _title_
- Set background title at top of screen
- --clear
- Clear screen on exit
- --colors
- Enable embedded color codes in dialog text
- --output-fd _fd_
- Output to specified file descriptor instead of stderr
FAQ
What is the dialog command used for?
dialog displays dialog boxes from shell scripts, providing a user-friendly text-based interface for interactive scripts. It supports various widget types including message boxes, input boxes, menus, checklists, radio lists, progress bars, and file selection dialogs. The program uses the ncurses library to create pseudo-graphical interfaces in text terminals. This enables shell scripts to present professional-looking user interfaces without requiring a graphical environment. Output is written to stderr (or a specified file), while exit status indicates which button was pressed (0 for OK/Yes, 1 for Cancel/No, 255 for ESC). This design allows scripts to capture both user selections and continue using stdout for other purposes. dialog is widely used in system administration scripts, installation programs, and configuration utilities.
How do I run a basic dialog example?
Run `dialog --msgbox "[Message]" [height] [width]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --msgbox _text_ _height_ _width_ do in dialog?
Display message with OK button