linux dialog 源码,Linux dialog详解(图形化shell)
4.密码框
格式:
dialog --passwordbox text height width [init]
例子:
1
2
# dialog --title "Password" --passwordbox \
"Please give a password for the new user:"
10
35
这样我们的密码就暴露出来了,是不是很不安全,所以通常我们会加上一个安全选项
--insecure 将每个字符用*来显示出来
1
2
# dialog --title "Password" --insecure \
--
passwordbox
"Please give a password for the new user:"
10
30
5.文本框
格式:dialog --textbox file height width
例子:
1
#dialog --title "The fstab" --textbox /etc/fstab 17 40
6.菜单框
格式:dialog --menu text height width menu-height tag1 item1 tag2 item2 …
例子:
1
2
#dialog --title "Pick a choice" --menu "Choose one" 12 35 5 \
1
"say hello to everyone"
2
"thanks for your support"
3
"exit"
7.Fselect框(文件选框)
格式:dialog --fselect filepath height width
例子:
1
#dialog --title "Pick one file" --fselect /root/ 7 40
8.复选框格式:dialog --checklist "Test" height width menu-height tag1 item1 tag2 item2 … 例子:
1
2
# dialog --backtitle "Checklist" --checklist "Test" 20 50 10 \
Memory
Memory
_Size
1
Dsik
Disk
_Size
2
<
b
>
<
/
b
>
9.显示日历格式:dialog --calendar "Date" height width day month year例子:#显示当前日期
1
# dialog --title "Calendar" --calendar "Date" 5 50
#显示指定日期
1
# dialog --title "Calendar" --calendar "Date" 5 50 1 2 2013
10.进度框架
格式:dialog --gauge text height width []
例子:
#固定进度显示
1
#dialog --title "installation pro" --gauge "installation" 10 30 10
#实时动度进度
1
2
#for i in {1..100} ;do echo $i;done | dialog --title \
"installation pro"
--
gauge
"installation"
10
30
#编辑到脚本中
编辑一个gauge.sh 的脚本
内容如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
# vim gauge.sh
declare
-
i
PERCENT
=
0
(
for
I
in
/
etc
/
*
;
do
if
[
$
PERCENT
-
le
100
]
;
then
cp
-
r
$
I
/
tmp
/
test
2
>
/
dev
/
null
echo
"XXX"
echo
"Copy the file $I ..."
echo
"XXX"
echo
$
PERCENT
fi
let
PERCENT
+=
1
sleep
0.1
done
)
|
dialog
--
title
"coping"
--
gauge
"starting to copy files..."
6
50
0
#bash gauge.sh (执行脚本的时候注意修改权限)
11.from框架(表单)
格式:dialog --form text height width formheight [ label y x item y x flen ilen ] ...
其中
flen 表示field length,定义了:选定字段中显示的长度
ilen 表示 input-length, 定义了:在外地输入的数据允许的长度
使用up/down(或ctrl/ N,ctrl/ P)在使用领域之间移动。使用tab键在窗口之间切换。
例子:
# 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
综合应用示例:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
yesno
(
)
{
dialog
--
title
"First screen"
--
backtitle
"Test Program"
--
clear
--
yesno
\
"Start this test program or not ? \nThis decesion have to make by you. "
16
51
# yes is 0, no is 1 , esc is 255
result
=
$
?
if
[
$
result
-
eq
1
]
;
then
exit
1
;
elif
[
$
result
-
eq
255
]
;
then
exit
255
;
fi
username
}
username
(
)
{
cat
/
dev
/
null
>
/
tmp
/
test
.
username
dialog
--
title
"Second screen"
--
backtitle
"Test Program"
--
clear
--
inputbox
\
"Please input your username (default: hello) "
16
51
"hello"
2
>
/
tmp
/
test
.
username
result
=
$
?
if
[
$
result
-
eq
1
]
;
then
yesno
elif
[
$
result
-
eq
255
]
;
then
exit
255
;
fi
password
}
password
(
)
{
cat
/
dev
/
null
>
/
tmp
/
test
.
password
dialog
--
insecure
--
title
"Third screen"
--
backtitle
"Test Program"
--
clear
--
passwordbox
\
"Please input your password (default: 123456) "
16
51
"123456"
2
>
/
tmp
/
test
.
password
result
=
$
?
if
[
$
result
-
eq
1
]
;
then
username
elif
[
$
result
-
eq
255
]
;
then
exit
255
;
fi
occupation
}
occupation
(
)
{
cat
/
dev
/
null
>
/
tmp
/
test
.
occupation
dialog
--
title
"Forth screen"
--
backtitle
"Test Program"
--
clear
--
menu
\
"Please choose your occupation: (default: IT)"
16
51
3
\
IT
"The worst occupation"
\
CEO
"The best occupation"
\
Teacher
"Not the best or worst"
2
>
/
tmp
/
test
.
occupation
result
=
$
?
if
[
$
result
-
eq
1
]
;
then
password
elif
[
$
result
-
eq
255
]
;
then
exit
255
;
fi
finish
}
finish
(
)
{
dialog
--
title
"Fifth screen"
--
backtitle
"Test Program"
--
clear
--
msgbox
\
"Congratulations! The test program has finished!\n Username: $(cat /tmp/test.username)\n Password: $(cat /tmp/test.password)\n Occupation: $(cat /tmp/test.occupation)"
16
51
result
=
$
?
if
[
$
result
-
eq
1
]
;
then
occupation
elif
[
$
result
-
eq
255
]
;
then
exit
255
;
fi
}
yesno
本文转自:http://gdcsy.blog.163.com/blog/static/1273436092013016069255/
本站整理:http://www.ttlsa.com/html/3085.html
linux dialog 源码,Linux dialog详解(图形化shell)相关推荐
- linux dialog详解(图形化shell)
liunx 下的dialog 工具是一个可以和shell脚本配合使用的文本界面下的创建对话框的工具. 每个对话框提供的输出有两种形式: 1. 将所有输出到stderr 输出,不显示到屏幕. ...
- Android4.0源码目录结构详解
Android4.0源码目录结构详解 Android4.0与2.1目录差不多 alsa这块,注意external/tinyalsa下有: include/tinyalsa/asoundlib.h mi ...
- Android 8.0学习(32)---Android 8.0源码目录结构详解
Android 8.0源码目录结构详解 android的移植按如下流程: (1)android linux 内核的普通驱动移植,让内核可以在目标平台上运行起来. (2)正确挂载文件系统 ...
- FreeRTOS之源码 及 移植详解
源:FreeRTOS之源码 及 移植详解 转载于:https://www.cnblogs.com/LittleTiger/p/9117856.html
- Nginx源码包安装详解
源码包安装详解 1.源码获取 2.如何安装源码 3.源码获取存放 3.1创建源码存放目录 3.2把源码移到需要存放的目录 3.3解压文件 3.4常用命令介绍 4.源码安装实际操作 4.1官网获取源码包 ...
- Spring IoC源码:getBean 详解
文章目录 Spring源码系列: 前言 正文 方法1:getObjectForBeanInstance 方法2:getObjectFromFactoryBean 方法3:doGetObjectFrom ...
- Linux操作系统内核源码目录结构详解
Linux内核源码目录结构 代码目录结构 在阅读源码之前,还应知道Linux内核源码的整体分布情况.现代的操作系统一般由进程管理.内存管理.文件系统.驱动程序和网络等组成.Linux内核源码的各个目录 ...
- 【Linux 内核】编译 Linux 内核 ① ( 下载指定版本的 Linux 内核源码 | Linux 内核版本号含义 | 主版本号 | 次版本号 | 小版本号 | 稳定版本 )
文章目录 一.下载 Linux 内核 1.下载最新版本 Linux 内核 2.下载指定版本 Linux 内核 二.Linux 内核版本号含义 一.下载 Linux 内核 1.下载最新版本 Linux ...
- linux下的Apache2 + mysql5 + php5 源码完整安装详解
由于公司要求下个项目得用PHP来开发,所以我不得不暂时放弃.net而钻入php的研究中...以下是我在linux下搭建php环境时所搜索到的相关资料以及自己的一些总结. 一:准备软件包,存放/ ...
最新文章
- 邮箱@topgrid.cn是什么网站_典 藏 网 站 !
- 继承与 Data Member(2)
- Linux--------------安装jdk
- PostgreSQL SystemTap on Linux 转
- 什么是卷影复制,卷影服务是什么
- 我的世界java版tis,我的世界1.7.10~1.8.8 9tis-3d回到汇编的时代mod
- POJ 3608 旋转卡壳
- mysql 安装目录配置_linux 下mysql安装,目录配置
- 2022年上半年软件设计师上午真题及答案解析
- 开发isv应用的权限处理
- 特征提取 --- 文本特征抽取
- 拆弹实验-phase_5
- 系统的学习linux
- stm32---DAC数模转换
- 郑州大学计算机专业本科毕业去向,河南计算机专业实力突出的7所大学,郑大位列次席,榜首实至名归...
- HTML5期末大作业:美食餐饮网站设计——酥麻辣祸-美食餐饮 HTML+CSS+JavaScript 学生DW网页设计
- 2022年华东师范大学计科考研复试机试题-详细题解
- Jenkins学习——邮件配置
- 《软件测试的艺术(第二版)》读后感
- Android视频加密那点事儿!
热门文章
- PS教程第一课:PS简介
- [js] js源代码压缩都有哪些方法?它们的压缩原理分别是什么
- 工作110:表格重置
- 前端学习(2312):react之路由基础
- 前端学习(565):margin重叠意义
- 前端学习(171):注释元素
- 第一百五十二期:白话Entity Framework Core数据验证
- java学习(104):字符串equals,charAt,endwith,startwith方法
- asp用于取代什么技术_苹果Mini LED晶粒四季度量产,用于新iPad Pro,三安光电或成赢家...
- rsync同步时,删除目标目录比源目录多余文件的方法(--delete)