dialog工具 在字符界面模拟生成文本窗口

dialog一般格式:
dialog --common-options --boxtype "Text" height with --box-specific-option
 
公共命令参数:
--backtitle 背景标题
--begin y x 设置纵横坐标
--colors 颜色
--title 正文标题
--defaultno 击键动作设置为no
--default-item 设置单选框的参数
--insecure 密码安全
--nocancle 不显示取消标签
--no-shadow 不显示窗体阴影
--nook   不显示ok 标签
--ok-lable sting          可将ok标签改其他字符
 
窗体模式:
--form
dialog --title "Add a user" --form "Please input the infomation of new user:" 12 40 4 \ “Username:” 1 1 “” 1 15(最大字符长度) 15 0(不限制长度) \ "Full name:" 2 1 "" 2 15 15 0 \"Home Dir:" 3 1 "" 3 15 15 0 \"Shell:" 4 1 "" 4 15 15 0
 

--fselect
dialog --title “Pick one file” --fselect /root/ 7 40
 

--gauge
Dialog –title “copying…” –gauge “Starting to copy file” 6 50 0
 
脚本实现:echo 不多于四个
 

--inputbox
dialog --title “Input your name” --inputbox “Please input your name:” 10 30 2> /tmp/name.txt
    

   
扩展标签用--extra-label string--extra-label reset
dialog --title “Input your name” ----extra-label “reset” --inputbox “Please input your name:” 10 30 2> /tmp/name.txt
 

--menu
dialog --title “pick a choice” --menu “Choose one” 12 35 5 1 “Display the disk usage” 2 “Display the meminfo” 3 “Exit”
 

--msgbox
dialog --colors --title Testing --msgbox “Z3This is a testZn” 10 20 2>dialog.out
 

用户输入的文本输出方式:标准错误输出2>
Dialog –colors –title “delste a file?” –ok-label “Submit” –msgbox “/Z2delete a file.” 7 20
 

 

一般标签名第一个字母大写 光标会默认指定到该字母上作为热键使用

--passwordbox
dialog --title "Password" --passwordbox "Please give a password for the new user:" 10 35
 
--textbox
dialog --title “The fstab” --textbox /etc/fstab 17 80
 
--yesno
dialog --title “Delete a file” --no-shadow --yesno “Delete the file /tmp/test.txt?” 7 35