[ 永远的UNIX::UNIX技术资料的宝库 ]

首页 > 编程技术 > 其它 > 正文

Linux程式设计-18.Dialog (11)配合Shell Script进阶使用

来源:http://www.openchess.org/noitatsko/programming/ (2001-05-27 11:00:00)

配合Shell Script进阶使用
单单知道每个功能如何使用是还不够的,一般您要需要知道如何配合Script来使用。 
会需要互动的有yesno、inputbox、menu、checklist、radiolist、gauge。 
yesno
例 
#!/bin/sh 
DIALOG=dialog 

if $DIALOG --title "WCW v.s. NWO" --backtitle "Wrestling"\ 
           --yesno "Are you ready to rumble?" 5 60; then 
  echo "Yeahhhhh" 
else 
  echo "Nap..." 
fi 

inputbox
例 
#!/bin/sh 
DIALOG=dialog 

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

gauge
到目前为止,gauge似乎都一直有点问题,文件上也写说是有点问题,所附的例程式也是无法使用,不建议您使用(我自己也玩不出来,你如果有试出来,请来信告诉我)。 

(http://www.fanqiang.com)



 
 相关文章

★  感谢所有的作者为我们学习技术知识提供了一条捷径  ★
www.fanqiang.com