linux dialog中文,linux dialog详解(图形化shell)

L3Byb3h5L2h0dHAvYmxvZ2ltZy5jaGluYXVuaXgubmV0L2Jsb2cvdXBmaWxlMi8xMDAzMTYxODQ1MTcucG5n.jpg

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

L3Byb3h5L2h0dHAvaW1nMi5waC4xMjYubmV0L2VmbU91enpHYVd1V0x3aGRmZlFBSFE9PS82NTk3ODE0MTM2MDI4OTM4MjcyLmpwZw==.jpg

综合应用示例:

#!/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

L3Byb3h5L2h0dHAvaW1nMi5waC4xMjYubmV0L3JyR0RCTGtyd25iUkRqMnZqME1UOGc9PS82NTk3ODA3NTM4OTU5MTc2MzkyLmpwZw==.jpg

L3Byb3h5L2h0dHAvaW1nOC5waC4xMjYubmV0L2R4ZS1FWEp1V1Q5Wklobm5uRTRZclE9PS82NTk3ODI1MTMxMTQ1MjIxNDk4LmpwZw==.jpg

L3Byb3h5L2h0dHAvaW1nMi5waC4xMjYubmV0L3Z3LW9OQ1NhTWRhaGVhNXhsa2J3SHc9PS82NTk3OTY4MDY3NjU2ODM1NDIyLmpwZw==.jpg

L3Byb3h5L2h0dHAvaW1nOC5waC4xMjYubmV0LzlQQUoxQkF6amExZlItWUpQcFQ0Y3c9PS82NTk3MzA3MjYxMTY4MDI5Mzk4LmpwZw==.jpg

L3Byb3h5L2h0dHAvaW1nMi5waC4xMjYubmV0L0JWZEhWSm0xQWJSUmhfSjVLTHBSVUE9PS82NTk4MjQwNzQ2NTQwMjk5NDcyLmpwZw==.jpg

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值