请问linux的dialog设计对话框不同的对话框可以嵌套吗?如果可以的话怎么嵌套呢? 财富值84

2016-10-26 13:29发布

比如下面这段shell脚本代码的各个对话框都是彼此独立的,我想把它们一起放到一个大对话框离里去,但不知道怎么弄:

/bin/bash

yesno()
{

dialog --title "First screen" --backtitle "Test Program" --clear --yesno      "Start this test program or not ? 
This 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!
 Username: $(cat /tmp/test.username)
 Password: $(cat /tmp/test.password)
 Occupation: $(cat /tmp/test.occupation)" 16 51  result=$? if [ $result -eq 1 ] ; then     occupation elif [ $result -eq 255 ]; then     exit 255; fi

}

yesno;

友情提示: 问题已经关闭,关闭后问题禁止继续编辑,回答。