首页 > 系统相关 >linux之whiptail交互式shell脚本对话框

linux之whiptail交互式shell脚本对话框

时间:2024-02-29 14:45:11浏览次数:20  
标签:shell OPTION 对话框 whiptail linux exitstatus

简单说明

当你在linux环境下setup软件的时候就会有相应的对话框让你输入。虽然我们已经习惯了这种交互的方法,但是如果有一种直观的界面来输入是不是会更加友好和方便呢,在shell脚本中你可以使用-whiptail指令来完成。

效果如下

[root@~]# cat test.sh
#!/bin/bash
OPTION=$(whiptail --title "Test Menu Dialog" --menu "Choose your option" 15 60 4 \
"1" "Grilled Spicy Sausage" \
"2" "Grilled Halloumi Cheese" \
"3" "Charcoaled Chicken Wings" \
"4" "Fried Aubergine"  3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
    echo "Your chosen option:" $OPTION
else
    echo "You chose Cancel."
fi
[root@~]# bash test.sh

参考链接

https://github.com/eryajf/magic-of-sysuse-scripts/blob/master/a

标签:shell,OPTION,对话框,whiptail,linux,exitstatus
From: https://www.cnblogs.com/yuhaohao/p/18043723

相关文章

  • Shell去除文件中重复的行
    需求一个a.txt文件中有很多ip和端口,在去重的同时,将每行中的多个空格替换为一个空格,输出文件中将保留后面出现的相同行,并且多个空格被替换为一个空格。脚本实现#!/bin/bash#设置输入文件和输出文件路径input_file="a.txt"output_file="unique_a.txt"#删除已存在的输出......
  • 初尝XShell破防实录
     一直纠结于connectionfailed没有登录,到头来failed是因为没有登录输入命令 sshusername@主机ip登录目前还没有设置免密登录这次的目的是安装conda了解到miniconda比anaconda更简洁,but好像大多数人都安装的事anaconda,关于XShell安装miniconda的教程以及问题解决就更少了......
  • linux shell 中实现进度条
     linux shell中实现进度条:#!/bin/bashtotal_steps=100for((step=1;step<=total_steps;step++));doprintf"\r[%-50s]%d%%"$(printf"#%.0s"$(seq1$((step*50/total_steps))))$((step*100/total_steps))sleep0.1#模拟操作延迟d......
  • Qt Virtual Keyboard C++集成与实现(解决模态对话框键盘失效问题)
    一.Qt模态对话框先让我们来看看对话框的几种特性:1.Qt::NonModaThewindowisnotmodalanddoesnotblockinputtootherwindows.2.Qt::WindowModalThewindowismodaltoasinglewindowhierarchyandblocksinputtoitsparentwindow,allgrandparentwin......
  • PowerShell 中,你可以使用一些命令来处理映像文件,包括挂载、捕捉、卸载、格式转换和编
    PowerShell中,你可以使用一些命令来处理映像文件,包括挂载、捕捉、卸载、格式转换和编辑映像。以下是一些常用的命令:挂载映像(MountImage):powershellCopyCodeMount-WindowsImage-ImagePath"C:\Path\To\Image.wim"-Path"C:\Mount\Directory"-Index1捕捉映像(CaptureIm......
  • powershell 电源管理命令
    PowerShell中,你可以使用以下命令来管理电源设置:Get-Command-ModulePowerManagement:查看可用的电源管理命令。Get-CimInstance-Namespaceroot\cimv2\power-ClassNameWin32_PowerPlan:获取当前系统中的电源计划信息。Get-CimInstance-Namespaceroot\cimv2\powe......
  • powershell遍历文件获取字段列表
    #指定要搜索的文件夹路径和正则表达式关键字$folderPath="C:\myapp\"$table_list="tblBOM,tblTest"$tables=$table_list.Split(',')foreach($tablein$tables){$regexPattern_field="$table\.(\w+......
  • BeanShell Sample 如何使用?
    一引入:eanShellSample主要用于生成一些逻辑复杂的数据,例如用于加解密数据;**每次调用前重置bsh.Interpreter:每个BeanShell副本都有自己的解释器副本(每个线程都有),**在循环内,如果没有勾选重置bs.Interpreter,那么解释器会保留在调用过程中,一些长时间运行的测试就会占用大......
  • powershell 5 信息收集命令
    PowerShell命令来查看当前用户及其权限:powershellCopyCode#获取当前登录的用户$env:USERNAME#获取计算机名称$env:COMPUTERNAME#检查当前用户是否为管理员([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([S......
  • Ubuntu20.04 系统 ALERT! UUID=xxx does not exist. Dropping to a shell!
    Gaveupwaitingforrootdevice.Commonproblems:-Bootargs(cat/proc/cmdline)-Checkrootdelay=(didthesystemwaitlongenough?)-Missingmodules(cat/proc/modules;ls/dev)ALERT!UUID=718ed077-947d-4018-80ad-59825678e81ddoesnotexist.Dropping......