-2

1) i want to write unix script which is like this

echo "Do u want to check application logs ???"
select opt in Yes No
    do
    case $opt in
    "Yes")
         commmands
     ;;
    "No")
    break
        ;;
    esac
    done

echo "Do u want to check non-application logs ???"
select opt in Yes No
    do
    case $opt in
    "Yes")
         commmands
     ;;
    "No")
    break
        ;;
    esac
    done

here after executing the first part its exiting and its asking the same thing again and again its not going to the other part i.e non-application logs

2)is this possible to use the two select and two case statements in the unix shell scripting if it is do please let me knoe the syntax.

1 Answer 1

1

From the bash help on select:

select: select NAME [in WORDS ... ;] do COMMANDS; done
...
COMMANDS are executed after each selection until a break command is executed

The break command you do have in there is breaking the case, not the select. You need to put a break outside the case block.

For example:

echo "Do u want to check application logs ???"
select opt in Yes No
do
    case $opt in
    "Yes")
        commmands
        ;;
    esac
    break
done

Also, since this case only has a single action, you might as well use an if, but I'll leave that to you.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.