linux--图形脚本

图形脚本

- 使用的人越来越多
- 图形能够使人更方便接受
- 运维更加倾向于人性化
- dialog

dialog

dialog工具可以用来创建终端图形对话框
在脚本中嵌入图形更加的直观

安装

yum install dialog -y

用法

作用:在shell环境中显示对话框
用法:dialog通用选项   对话框选项
通用选项:
    --backtitle        背景标题
    --begin y x     指定对话框坐标y为水平坐标,x为垂直坐标
    --clear            清屏
    --height        高度
    --width            宽度
    --title            对话框标题
    --insecure        密码人性化,不安全


#通用选项就是对所有对话框有效可用的属性,对话框属性则是针对某种具体对话框的特殊选项
#dialog支持对话框类型较多 文件对话框 消息对话框  密码对话框 确认对话框

案例

1.日历对话框
语法格式:--calendar text height width day month year
calenda指定对话框为日历对话框,title设置对话框标题,text为对话框中的提示符,可以输入任意字符
day month year 分别为日历对话框默认显示时间
如果命令中没有指定日期,则dialog将默认显示系统当前日期

[root@server0 programe]# dialog --title "CALENDAR Kuang" --calendar "plese choose a date......" 0 0 12 12 1999

2.选择对话框
语法格式:--checklist text height width list-height [ tag item status ] ...
checklist指定对话框为检查对话框,text为提示符,list-height设置列表高度
tag 为每个选择项目的标签
item为具体选项内容
status默认状态(on或off)

oot@server0 programe]# dialog --checklist "Select" 10 40 8 1 "Man" "on"  2 "Woman" "off"  3 "Man&Woman" "off"

3.图形进度条
语法格式: --gauge text height width [percent]
percent代表进度值   10代表10%    该模式不会自动退出  ctrl+c
root@server0 programe]# dialog --title "Gauge" --gauge "*************"  6 60 20



4.图形密码框
语法格式:--passwordbox text height width [init]
[root@server0 programe]# dialog --title "PASSWORDBOX" --passwordbox "INPUT YOUR PASSWORD" 123 35

5.消息框
语法格式:--msgbox text height width

[root@server0 programe]# dialog --title "Message" --clear --msgbox "Hello world" 6 25


6.确认框
语法格式:--yesno text height width
[root@server0 programe]# dialog --title "Yes or No" --clear --yesno "Are you Sure?" 6 30    

copy文件显示进度条

#!/bin/bash
declare -i PERCENT=0
(
    for I in /etc/*;do
        if [ $PERCENT -le 100 ];then
            cp -r $I /tmp/text 2> /dev/null
            echo "************************"
            echo "Copy the file $I..."
            echo "************************"
            echo $PERCENT
        fi
    let PERCENT+=1
    sleep 0.5
    done 
) | dialog --title "copy file gauge"  --gauge "starting to copy $I..." 6 50 0
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值