博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
8.4. whiptail - display dialog boxes from shell scripts
阅读量:7047 次
发布时间:2019-06-28

本文共 5864 字,大约阅读时间需要 19 分钟。

8.4.1. --msgbox

whiptail --title "Example Dialog" --msgbox "This is an example of a message box. You must hit OK to continue." 8 78
┌─────────────────────────────┤ Example Dialog ├─────────────────────────────┐  │                                                                            │  │ This is an example of a message box. You must hit OK to continue.          │  │                                                                            │  │                                                                            │  │                                   
│ │ │ └────────────────────────────────────────────────────────────────────────────┘

8.4.2. --infobox

whiptail --title "Example Dialog" --infobox "This is an example of a message box. You must hit OK to continue." 8 78

8.4.3. --yesno

例 8.1. whiptail - yesno

#! /bin/bash# http://archives.seul.org/seul/project/Feb-1998/msg00069.htmlif (whiptail --title "PPP Configuration" --backtitle "Welcome to SEUL" --yesno "Do you want to configure your PPP connection?"  10 40 )then         echo -e "\nWell, you better get busy!\n"elif    (whiptail --title "PPP Configuration" --backtitle "Welcome toSEUL" --yesno "           Are you sure?" 7 40)        then                echo -e "\nGood, because I can't do that yet!\n"        else                echo -e "\nToo bad, I can't do that yet\n"fi
whiptail --title "Example Dialog" --yesno "This is an example of a yes/no box." 8 78 exitstatus=$?if [ $exitstatus = 0 ]; then    echo "User selected Yes."else    echo "User selected No."fi echo "(Exit status was $exitstatus)"

设置--yes-button,--no-button,--ok-button 按钮的文本

whiptail --title "Example Dialog" --yesno "This is an example of a message box. You must hit OK to continue." 8 78 --no-button 取消 --yes-button 确认

8.4.4. --inputbox

例 8.2. whiptail - inputbox

result=$(tempfile) ; chmod go-rw $resultwhiptail --inputbox "Enter some text" 10 30 2>$resultecho Result=$(cat $result)rm $result
┌────────────────────────────┐                                                  │ Enter some text            │                                                  │                            │                                                  │ __________________________ │                                                  │                            │                                                  │                            │                                                  │                            │                                                  │    
│ │ │ └────────────────────────────┘
COLOR=$(whiptail --inputbox "What is your favorite Color?" 8 78 --title "Example Dialog" 3>&1 1>&2 2>&3) exitstatus=$?if [ $exitstatus = 0 ]; then    echo "User selected Ok and entered " $COLORelse    echo "User selected Cancel."fi echo "(Exit status was $exitstatus)"

8.4.5. --passwordbox

例 8.3. whiptail - passwordbox

whiptail --title "Example Dialog" --passwordbox "This is an example of a password box. You must hit OK to continue." 8 78

8.4.6. --textbox

例 8.4. whiptail - passwordbox

whiptail --title "Example Dialog" --textbox /etc/passwd 20 60

为文本取添加滚动条功能

whiptail --title "Example Dialog" --textbox /etc/passwd 20 60 --scrolltext

8.4.7. --checklist

例 8.5. whiptail - example 1

whiptail --title "Check list example" --checklist \"Choose user's permissions" 20 78 16 \"NET_OUTBOUND" "Allow connections to other hosts" ON \"NET_INBOUND" "Allow connections from other hosts" OFF \"LOCAL_MOUNT" "Allow mounting of local devices" OFF \"REMOTE_MOUNT" "Allow mounting of remote devices" OFF

8.4.8. --radiolist

例 8.6. whiptail - radiolist

whiptail --title "Check list example" --radiolist \"Choose user's permissions" 20 78 16 \"NET_OUTBOUND" "Allow connections to other hosts" ON \"NET_INBOUND" "Allow connections from other hosts" OFF \"LOCAL_MOUNT" "Allow mounting of local devices" OFF \"REMOTE_MOUNT" "Allow mounting of remote devices" OFF

8.4.9. --menu

whiptail --title "Menu example" --menu "Choose an option" 22 78 16 \"<-- Back" "Return to the main menu." \"Add User" "Add a user to the system." \"Modify User" "Modify an existing user." \"List Users" "List all users on the system." \"Add Group" "Add a user group to the system." \"Modify Group" "Modify a group and its list of members." \"List Groups" "List all groups on the system."
┌──────────────────────────────┤ Menu example ├──────────────────────────────┐  │            <-- Back     Return to the main menu.                           │  │            Add User     Add a user to the system.                          │  │            Modify User  Modify an existing user.                           │  │            List Users   List all users on the system.                      │  │            Add Group    Add a user group to the system.                    │  │            Modify Group Modify a group and its list of members.            │  │            List Groups  List all groups on the system.                     │  │                                                                            │  │                                                                            │  │                    
│ │ │ └────────────────────────────────────────────────────────────────────────────┘

8.4.10. --gauge

#!/bin/bash{    for ((i = 0 ; i <= 100 ; i+=30)); do        sleep 1        echo $i    done} | whiptail --gauge "Please wait" 5 50 0

原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

你可能感兴趣的文章
WPF PRISM开发入门二(Unity依赖注入容器使用)
查看>>
使用 data-* 属性来嵌入自定义数据:
查看>>
炒股的常见技术指标
查看>>
工控随笔_07_西门子_WinCC利用命令行实现操作log日志
查看>>
解决MySQL报错The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents ........
查看>>
(筆記) 如何設計邊緣檢測電路? (SOC) (Verilog)
查看>>
MPEG文件中什么是GOP
查看>>
C#查找指定窗口的子窗口的句柄
查看>>
Linux man命令的使用方法
查看>>
在delphi中嵌入脚本语言--(译)RemObjects Pascal Script使用说明(1)(译)
查看>>
Icon cache rebuilding with Delphi(Delphi 清除Windows 图标缓存源代码)
查看>>
Azure VMSS (2) 对VM执行Generalize操作
查看>>
C# 4.0四大新特性代码示例与解读
查看>>
HUST 1017 Exact cover
查看>>
SessionStateStoreProviderBase.GetItemExclusive Method
查看>>
Excel Wrapper
查看>>
Thread和Service应用场合的区别
查看>>
poj 2632 模拟题
查看>>
递归--木棍问题
查看>>
企业门户(Portal)项目实施方略与开发指南
查看>>