whiptail

Whiptail

info
namewhiptail
full namewhiptail
aliaseswhiptail
tagstui

Linux TUI

whiptail --title "Message" --msgbox "Hello, World" 10 40
  • whiptail [WIDGET] [OPTIONS…]
  • [WIDGET]
    • –msgbox TEXT HEIGHT WIDTH
    • –yesno TEXT HEIGHT WIDTH
    • –infobox TEXT HEIGHT WIDTH [INIT]
    • –passwordbox TEXT HEIGHT WIDTH [INIT]
    • –textbox TEXT HEIGHT WIDTH
    • –menu TEXT HEIGHT WIDTH LIST_HEIGHT [TAG ITEM]…
    • –checklist TEXT HEIGHT WIDTH LIST_HEIGHT [TAG ITEM STATUS]…
    • –radiolist TEXT HEIGHT WIDTH LIST_HEIGHT [TAG ITEM STATUS]…
    • –gauge TEXT HEIGHT WIDTH PERCENT
  • [OPTIONS…]
    • –clear: clear screen on exit
    • –defaultno: default no button
    • –default-item STRING: set default string
    • –fullbuttons, –fb: use full buttons
    • –nocancel: no cancel button
    • –yes-button TEXT: set text of yes button
    • –no-button TEXT: set text of no button
    • –ok-button TEXT set text of ok button
    • –cancel-button TEXT set text of cancel button
    • –noitem: don't display items
    • –notags: don't display tags
    • –separate-output: output one line at a time
    • –output-fd FD: output to fd, not stdout
    • –title TITLE: display title
    • –backtitle BACK_TITLE: display backtitle
    • –scrolltext: force vertical scrollbars
    • –topleft: put window in top-left corner
    • –help, -h: print this message
    • –version, -v: print version information
종료시 0(성공), 1(취소), 255(ESC, ERROR) 코드가 발생

whiptail

#!/bin/bash
 
# 제목 설정
TITLE="시스템 설정 도구"
 
# 메뉴 선택
action=$(whiptail --menu "$TITLE" 15 40 4 \
    "1" "네트워크 설정" \
    "2" "사용자 추가" \
    "3" "서비스 재시작" 3>&1 1>&2 2>&3)
 
case $action in
    "1") /path/to/network-setup.sh ;;
    "2") /path/to/user-add.sh ;;
    "3") systemctl restart some-service ;;
    *) echo "취소됨" ;;
esac
if whiptail --yesno "파일을 삭제하시겠습니까?" 10 30; then
    echo "삭제됨"
else
    echo "취소됨"
fi
choice=$(whiptail --menu "옵션을 선택하세요" 15 30 4 \
    "1" "설치" \
    "2" "제거" \
    "3" "업데이트" 3>&1 1>&2 2>&3)
 
echo "선택: $choice"
options=$(whiptail --checklist "패키지 선택" 15 40 4 \
    "nginx" "웹 서버" OFF \
    "mysql" "데이터베이스" ON \
    "php" "PHP 언어" OFF 3>&1 1>&2 2>&3)
 
echo "선택된 항목: $options"
{
    for i in {1..100}; do
        echo $i
        sleep 0.1
    done
} | whiptail --gauge "처리 중..." 6 50 0
  • whiptail.txt
  • 마지막으로 수정됨: 2025/02/04 02:05
  • 저자 writer