BBS水木清华站∶精华区

翻译by GaryLee!! 
 
dialog 使用说明: 
 
名称: 
        dialog - 由shell script中, 显示对话框! 
 
语法: 
        dialog --clear 
        dialog --create-rc file 
        dialog [--title title] [--clear] box-options 
 
描述: 
        Dialog是一个可以让你显示各种讯息或者是讯问问题, 要求输入资料的 
        一个程式, 可以在shell script中使用. 目前有支援下面几种形态的对 
        话框: 
 
        yes/no box      -- YES/NO讯息框 
        menu box        -- 选单讯息框 
        input box       -- 输入框 
        message box     -- 讯息显示框 
        text box        -- 文字显示框 
        info box        -- 资讯显示框 
        checklist box   -- 选项确定列表框 
 
选项: 
 
        --clear 
                清除萤幕 
 
        --create-rc file 
                因为dialog支援run-time configuration, 所以这个选项可以用 
                在倾印出目前的configuration的状况到file所指定的档案中. 
 
        --title title 
                用来指定显示在对话框上方的字串. 
 
 
    BOX OPTIONs 
        --yesno text height width 
                在萤幕上show出一个width x height大小的对话框, 同时这个对 
                话框会有一个yes及一个no的选择项. 同时对话框内会显示text所 
                指定的字串. 如果要将该字串断行, 可以加入换行字元"\n". 
                如果想要在yes及no的选择中切换, 可用tab键!! 
 
                EXAMPLE: 
 
                dialog --yesno "Are you sure?" 7 30 
 
        --msgbox text height width 
                在萤幕上show出一个width x height大小的对话框, 同时这个对 
                话框会有一个OK的选项. 按ENTER後可以离开. 其他的部份与 
                yes/no box相同. 
 
                EXAMPLE: 
 
                dialog --msgbox "Hello, Dialog Box" 7 30 
 
        --infobox text height width 
                这是一个简单的message box, dialog在显示完text所指定的字串 
                後, 会立即结束. 但不会将萤幕清除, 除非你呼叫其他的dialog 
                选项来清除它. 当你想show一些message给user时, 然後在一段时 
                间後自动清除它时, 就可以用这个选项. 
 
                EXAMPLE: 
 
                dialog --infobox "abcdefg\n1234567890" 6 20 
                sleep 5 
                dialog --clear 
 
        --inputbox text height width 
                在萤幕上show出一个width x height大小的对话框, 同时这个对 
                话框之中还会有一个输入框, 让user输入文字, text所指定的提示 
                字串则会show在输入框的上方. user输入的文字会由stderr中show 
                出. 
 
                EXAMPLE: 
 
                dialog --inputbox "Name :" 10 30 2> yourname.tmp 
                cat yourname.tmp 
 
        --textbox file height width 
                和message box相同, 唯一不同在於message box的讯息是用text 
                选项所指定的字串, 而text box的讯息则是使用file选项所指定的 
                档案中的内容. 若文章的大小超过box的大小, 可以用UP/DOWN, 
                PGUP/PGDN, HOME/END, 以及LEFT/RIGHT等键来移动显示文字的 
                □围. 
 
                EXAMPLE: 
 
                dialog --textbox /etc/hosts 20 70 
 
        --menubox text height width menu-height [ tag item ] ... 
                这个对话框会提供一系列的选单来让使用者选择, 每个选项包含 
                了一个标签字串(tag string). 以及一个选项提示字串(item 
                string) tag string是用来分别不同的item用的,  item string 
                则是用来, 显示在萤幕上给user看的, 主要是用来描述这个item. 
                user可以用UP/DOWN来在不同的选项间移动. menu-height是用来 
                指定一次要在萤幕上show的item的数目. 当dialog结束後, 会把 
                user所选择的item的tag string输出到stderr上. 
 
                EXAMPLE: 
 
                dialog --menubox "your choice?" 20 40 10 item1 "item 1" \ 
                item2 "item 2" item3 "item 3" item4 "item 4" 2> choice.tmp 
                cat choice.tmp 
 
        --checklist text height width list-height [ tag item status ] ... 
                和menu box类似, 不同的地方在於menu box一次仅能选择一个 
                item, 而checklist box则可以同时指定数个item. 个选项的功用 
                也差不多, 其中list-height跟menu-height是相同的. 至於 
                status所代表的意义则是否要一开始就先帮使用者选取该item, 
                既所谓的default选项, status的可以为on或是off. dialog执行 
                结束後, 被选到的item的tag string将会输出到stderr上. 
 
                EXAMPLE: 
 
                dialog --checklist "your choices?" 20 40 10 \ 
                item1 "item one" on \ 
                item2 "item two" off \ 
                item3 "item three" on \ 
                item4 "item four" on \ 
                item5 "item five" off \ 
                item6 "item six" off 2> choices.tmp 
                cat choices.tmp 
 
dialog之exit status: 
        如果dialog的exit status是0的话,  表示YES或是OK的button被按下. 如 
        果是1 的话表示NO或CANCEL button被按下, 如果有错误发生, 或是被按下 
        ESC键结束的话, 则exit status为-1. 
 

BBS水木清华站∶精华区