yoavbe
February 6, 2008, 11:24am
1
Hi,
I need your help co create a very small menu somthing that look like this:
first step
second step
last step
from step : ___
to step : ___
If the user choose 1 --> it will echo : Hellow
If the user choose 2 --> it will echo : World
If the user choose 3 --> it will echo : Bye
If the the user choose from 1 to 2 --> it will echo : Hello
World
And so on.
Thank you very much for your help.
echo 1. first step
echo 2. second step
echo 3. last step
echo 4. from step:_ to step:
FIRST=hello
SECOND=WORLD
LAST=Bye
read CHOICE
case $CHOICE in
1) echo $FIRST ;;
2) echo $SECOND ;;
3) echo $LAST ;;
4) read -p step1: ONE; read -p step2: TWO
case $ONE$TWO in
11) echo $FIRST ;;
12) echo $FIRST $SECOND ;;
13) echo $FIRST $SECOND $LAST ;;
22) echo $SECOND ;;
23) echo $SECOND $LAST ;;
33) echo $LAST ;;
esac
esac
HPAVC
February 6, 2008, 1:09pm
3
The program 'dialog' does a good job of this type of work it seems:
Dialog: An Introductory Tutorial
yoavbe
February 7, 2008, 6:54am
4
Hi ,
I runed the code above. if i choose just one option its work fine.
But if i choose to run it between two option its retun nathing.
For example:
/software >./tafrit.sh
first step
second step
last step
from step:_ to step:
2
WORLD
/software >./tafrit.sh
first step
second step
last step
from step:_ to step:
12
/software >
Thanks.
funksen
February 8, 2008, 10:18am
5
hm you are right, doesn't work, somethings wrong with the semicolons
this one should work:
echo 1. first step
echo 2. second step
echo 3. last step
echo 4. from step:_ to step:
FIRST=hello
SECOND=WORLD
LAST=Bye
FROMTO()
{
case $ONE$TWO in
11) echo $FIRST ;;
12) echo $FIRST $SECOND ;;
13) echo $FIRST $SECOND $LAST ;;
22) echo $SECOND ;;
23) echo $SECOND $LAST ;;
33) echo $LAST ;;
esac
}
read CHOICE
case $CHOICE in
1) echo $FIRST ;;
2) echo $SECOND ;;
3) echo $LAST ;;
4) read -p step1: ONE; read -p step2: TWO; FROMTO;;
esac