比如下面這段shell腳本代碼的各個對話框都是彼此獨(dú)立的,我想把它們一起放到一個大對話框離里去,但不知道怎么弄:
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; fiusername;
}
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.usernameresult=$? if [ $result -eq 1 ] ; then yesno; elif [ $result -eq 255 ]; then exit 255; fipassword;
}
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.passwordresult=$? if [ $result -eq 1 ] ; then username; elif [ $result -eq 255 ]; then exit 255; fioccupation;
}
occupation()
{
cat /dev/null >/tmp/test.occupation dialog --title "Forth screen" --backtitle "Test Program" --clear --menu"Please choose your occupation: (default: IT)" 16 51 3IT "The worst occupation"CEO "The best occupation"Teacher "Not the best or worst"2>/tmp/test.occupationresult=$? if [ $result -eq 1 ] ; then password; elif [ $result -eq 255 ]; then exit 255; fifinish;
}
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 51result=$? if [ $result -eq 1 ] ; then occupation elif [ $result -eq 255 ]; then exit 255; fi
}
yesno;