推荐阅读

Helm3(K8S 资源对象管理工具)视频教程:https://edu.csdn.net/course/detail/32506
Helm3(K8S 资源对象管理工具)博客专栏:https://blog.csdn.net/xzk9381/category_10895812.html

本文原文链接:https://blog.csdn.net/xzk9381/article/details/116054435,转载请注明出处。如有发现文章中的任何问题,欢迎评论区留言。

一、消息框

# 语法
whiptail --title "<message box title>" --msgbox "<text to show>" <height> <width># 实例
whiptail --title "Message box title" --msgbox " Choose Ok to continue." 10 60

二、Yes/No对话框(选择左边的选项返回值为0,选择右边的选项返回值为1)

# 语法
whiptail --title "<dialog box title>" --yesno "<text to show>" <height> <width># 实例
#!/bin/bash
if (whiptail --title "Yes/No Box" --yesno "Choose between Yes and No." 10 60) thenecho "You chose Yes. Exit status was $?."
elseecho "You chose No. Exit status was $?."
fi# 或者也可以是自定义选项
#!/bin/bash
if (whiptail --title "Yes/No Box" --yes-button "Man" --no-button "Woman"  --yesno "What is your gender?" 10 60) thenecho "You chose Man Exit status was $?."
elseecho "You chose Woman. Exit status was $?."
fi

三、表单输入框

#语法
whiptail --title "<input box title>" --inputbox "<text to show>" <height> <width> <default-text>#实例
#!/bin/bash
NAME=$(whiptail --title "Free-form Input Box" --inputbox "What is your pet's name?" 10 60 Peter 3>&1 1>&2 2>&3)exitstatus=$?
if [ $exitstatus = 0 ]; thenecho "Your name is:" $NAME
elseecho "You chose Cancel."
fi

四、密码输入框

# 语法
whiptail --title "<password box title>" --passwordbox "<text to show>" <height> <width># 实例
#!/bin/bash
PASSWORD=$(whiptail --title "Password Box" --passwordbox "Enter your password and choose Ok to continue." 10 60 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; thenecho "Your password is:" $PASSWORD
elseecho "You chose Cancel."
fi

五、菜单栏

# 语法
whiptail --title "<menu title>" --menu "<text to show>" <height> <width> <menu height> [ <tag> <item> ] # 实例
#!/bin/bash
OPTION=$(whiptail --title "Menu Dialog" --menu "Choose your favorite programming language." 15 60 4 \
"1" "Python" \
"2" "Java" \
"3" "C" \
"4" "PHP"  3>&1 1>&2 2>&3)exitstatus=$?
if [ $exitstatus = 0 ]; thenecho "Your favorite programming language is:" $OPTION
elseecho "You chose Cancel."
fi# 此处的选择输出的内容为你选择的标签的‘tag’位置,上面实例中的‘1’、‘2’、‘3’、‘4’

六、 radiolist对话框( 单选对话框,可以控制默认的选择位置,即使在脚本中默认选择多个,也只会输出一个结果)

# 语法
whiptail --title "<radiolist title>" --radiolist "<text to show>" <height> <width> <list height> [ <tag> <item> <status> ] . . .# 实例
#!/bin/bash
DISTROS=$(whiptail --title "Test Checklist Dialog" --radiolist \
"What is the Linux distro of your choice?" 15 60 4 \
"debian" "Venerable Debian" ON \
"ubuntu" "Popular Ubuntu" OFF \
"centos" "Stable CentOS" OFF \
"mint" "Rising Star Mint" OFF 3>&1 1>&2 2>&3)exitstatus=$?
if [ $exitstatus = 0 ]; thenecho "The chosen distro is:" $DISTROS
elseecho "You chose Cancel."
fi

七、多选对话框

# 语法
whiptail --title "<checklist title>" --checklist "<text to show>" <height> <width> <list height> [ <tag> <item> <status> ] . . .# 实例
#!/bin/bash
DISTROS=$(whiptail --title "Checklist Dialog" --checklist \
"Choose preferred Linux distros" 15 60 4 \
"debian" "Venerable Debian" ON \
"ubuntu" "Popular Ubuntu" OFF \
"centos" "Stable CentOS" ON \
"mint" "Rising Star Mint" OFF 3>&1 1>&2 2>&3)exitstatus=$?
if [ $exitstatus = 0 ]; thenecho "Your favorite distros are:" $DISTROS
elseecho "You chose Cancel."
fi

八、进度条

# 语法
whiptail --gauge "<test to show>" <height> <width> <inital percent># 实例
#!/bin/bash
{for ((i = 0 ; i <= 100 ; i+=20)); dosleep 1echo $idone} | whiptail --gauge "Please wait while installing" 6 60 0

本文原文链接:https://blog.csdn.net/xzk9381/article/details/116054435,转载请注明出处。如有发现文章中的任何问题,欢迎评论区留言。

交互式SHELL脚本对话框(whiptail)相关推荐

  1. 2021-10-26 linux 交互式shell脚本对话框----whiptail指令

    一.编译Android kernel的时候弹出一个选择对话框,比较好奇,就认真分析了一下这个脚本对话框怎么来的. 1.编译的时候会调用mkimg文件. 2.mkimg文件里面会调用whiptail指令 ...

  2. 创建交互式shell脚本对话框

    当你在终端环境下安装新的软件时,你可以经常看到信息对话框弹出,需要你的输入,比如:RHEL/CentOS自带的setup,对话框的类型有密码箱.检查表.菜单等等.他们可以引导你以一种直观的方式输入必要 ...

  3. 详解Linux交互式shell脚本中创建对话框实例教程

    详解Linux交互式shell脚本中创建对话框实例教程 本教程我们通过实现来讲讲Linux交互式shell脚本中创建各种各样对话框,对话框在Linux中可以友好的提示操作者,感兴趣的朋友可以参考学习一 ...

  4. 详解Linux交互式shell脚本中创建对话框实例教程_linux服务器

    本教程我们通过实现来讲讲Linux交互式shell脚本中创建各种各样对话框,对话框在Linux中可以友好的提示操作者,感兴趣的朋友可以参考学习一下. 当你在终端环境下安装新的软件时,你可以经常看到信息 ...

  5. 交互式shell脚本实操

    在Linux 编程中有时我们会用到shell脚本来帮我们做一些事情,但涉及到交互中需要人为交互的部分如果想自动化运行就比较麻烦,但shell操作中其实是考虑到这点的.下面我以一个例子来简要的说明,当然 ...

  6. 【Linux】《Linux命令行与shell脚本编程大全 (第4版) 》笔记-汇总 ( Chapter17-ChapterB )

    十七.创建函数 bash shell 提供了用户自定义函数功能,可以将 shell 脚本代码放入函数中封装起来. 函数是一个脚本代码块,你可以为其命名并在脚本中的任何位置重用它.每当需要在脚本中使用该 ...

  7. 图形化桌面环境中的shell脚本编程

    图形化桌面环境中的脚本编程 2.1 创建文本菜单 创建交互式 shell 脚本最常用的方法是使用菜单.提供各种选项可以帮助脚本用户了解脚本能做什么和不能做什么. 通常菜单脚本会清空显示区域,然后显示可 ...

  8. Linux_《Linux命令行与shell脚本编程大全》第十八章学习总结

    时间:2017年12月04日星期一 说明:本文部分内容均摘取自书籍<Linux命令行与shell脚本编程大全>,版权归原作者所有.<Linux命令行与shell脚本编程大全>( ...

  9. shell 脚本 基础

    简介: Shell 是一个用C语言编写的程序,它是用户使用Linux的桥梁.Shell既是一种命令语言,又是一种程序设计语言. Shell 是指一种应用程序,这个应用程序提供了一个界面,用户通过这个界 ...

最新文章

  1. A and B and Lecture Rooms CodeForces - 519E LCA+dfs序
  2. 嵌入在C++程序中的extern C
  3. Supervisor重新加载配置启动新的进程
  4. mysql被更新失败_更新mysql出错:出错原因 You are using safe update mode
  5. 程序相关概念及OS Linux发行版
  6. delphi xe5 android,android – 发送电子邮件Delphi XE5
  7. PAT乙级 1097 矩阵行平移
  8. 【项目管理】干系人绩效域管理
  9. 1000+常用Python库大全,太实用了!
  10. 命令行批量缩小图片尺寸
  11. 微信短信显示服务器解包异常,最新微信小程序解包反编译bug处理 解决 $gwx is not defined 错误...
  12. Python基础——魔法方法与异常处理
  13. java计算机毕业设计教师继续教育MyBatis+系统+LW文档+源码+调试部署
  14. 视频号扩展链接一键转换文章链接
  15. 图像处理之天空区域识别
  16. .Net内部缓存System.Web.Caching.Cache 和Redis缓存缓存工厂切换
  17. 如何在Mac OS X下制作dmg格式的镜像
  18. 关于Vue中常用指令总结
  19. CANOpen 配置对象字典 $NODEID
  20. 读懂8K慢直播对于文旅产业振兴的意义

热门文章

  1. UVALive6336 HDU4450 Draw Something【水题】
  2. CCF NOI1050 矩阵乘法
  3. 英语单词辨异 —— 容易理解错的单词
  4. Theano 编程核心
  5. shell 操作(四)
  6. Python 2.x vs Python 3(三)
  7. 从排列与组合的python实现到生日问题的解释
  8. C++11::遍历tuple中的元素
  9. mysql 字段加减_MySQL数据库开发常见问题及优化(续)
  10. python为什么叫爬虫-可以写爬虫的那么多,为什么只有python火了?