shell---dialog

参数详解:

dialog --clear         

整个萤幕会清除後离开

dialog --create-rc file

dialog支援动态规划,这个功能会产生一个样本。

--title title          

对话盒上的标题文字

--backtitle backtitle  

桌面背景的标题

box-options            

dialog目前提供了yes/no  box,  menu  box, input box, message box, text box, info box, checklist box, radiolist box, 及gauge box共九种widget.

Exit Status            

如果按下Yes或OK按键.则会返回0.No或Cancel会返回1.如果按下ESC或发生错误.则会返回-1


--yesno text height width

# dialog --title "hello" --backtitle "Dialog" --yesno "Is everything okay" 20 60

--msgbox text height width

# dialog --title "hello" --backtitle "Dialog" --msgbox "Is everything okay" 20 60

--infobox text height width

# dialog --title "hello" --backtitle "Dialog" --infobox "Is everything okay?" 10 60

Infobox会在显示讯息後立即离开,在console的状况下,讯息会留下,但在X Terminal下,由於X Terminal会立即将讯息清除,Screen Shot抓不到,因此这里没有ScreenShot。您可以在console下测试。

--inputbox text height width [init]

# dialog --title "hello" --backtitle "Dialog" --inputbox "Is okay?" 10 60 "yes"

--textbox file height width

[foxman@foxman copyright]# dialog --title "Array 30" --backtitle "All " --textbox file 20 75

textbox很像是个简单的text viewer,它会显示档案中的文字。

--menu text height width menu-height [ tag item ] ...

# dialog --title "Menu Example" --menu "MENU" 20 60 4 tag1 " item1" tag2 "item2" tag3 "item3" tag4 "item4"

--checklist text height width list-height [ tag item status ] ...

# dialog --title "CheckList Example" --checklist "Check List" 20 60 4 tag1 "item1" on tag2 "item2" off tag3 "item3" on tag4 "item4" off

--radiolist text height width list-height  [ tag  item status  ] ...

# dialog --title "RadioList Example" --radiolist "Radio List" 20 60 4 tag1 "item1" on tag2 "item2" off tag3 "item3" on tag4 "item4" off

--gauge text height width percent

# dialog --title "Installation" --backtitle "Star Linux" --gauge "Linux Kernel"  10 60 50

gauge widget在启动後,会从stdin读取percent进来,读到EOF时结束。

范例:

yesno

if dialog --title "title" --backtitle "backtitle"

--yesno "Are you ready to rumble?" 5 60; then
   echo "Yeahhhhh"
else
   echo "Nap..."
fi  

inputbox

if dialog --title "The future is here" 

--inputbox "Where do you want to go tomorrow?"

10 75 "Penguin" 2>my_own_destiny;then
  way=`cat my_own_destiny`
  echo "My way is $way"
else
  echo "freak out"
fi  

menu 

if dialog --title "title" --menu "MENU" 20 60 14

tag1 "item1" tag2 "item2" 2>select ;then
  selection=`cat select`
  echo "my selection is $selection"
else
  echo "go"
fi
checklist

if dialog --title "title" --checklist "checklist"

20 60 14 tag1 "item1" on tag2 "item2" off 2>select ;then
  selections=`cat select`
  echo "My selections are:"
  for i in $selections ; do
    echo $i
  done
else
  echo "go"
fi

radiolist

if dialog --title "title" --radiolist "checklist"

20 60 14 tag1 "item1" on tag2 "item2" off 2>select;then
  selection=`cat select`
  echo "My selection is $selection"
else
  echo "go"
fi

转载于:https://my.oschina.net/jonetwelve/blog/617189

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值