How to display an error msg?

Hi friends,
Please suggest a solution for this.
A script has following things.

echo "Enter P for PML"
echo "Enter V for VVL"
echo "Enter L for LNL"
echo "Enter G for GDL"
read choice
echo ${choice} >> LOG_Daily.txt

if operator enters anything other that P/V/L/G it should show an error msg like "Wrong media Choice; Please try again"

Thanx in advance
Anushree.

echo
echo "1 - Enter P for PML"
echo "2 - Enter V for VVL"
echo "3 - Enter L for LNL"
echo
echo "Select: \c"
read INPUT

case "$INPUT"
in
1) Do some operations for P ;;
2) Do some operations for V ;;
3) Do some operations for L ;;

*\)  echo "Wrong media Choice Please try again"

    ;;

esac

#!/bin/bash

while 1
do
    echo "Enter P for PML"
    echo "Enter V for VVL"
    echo "Enter L for LNL"
    echo "Enter G for GDL"
    read choice
    case $choice in
        [qQ]) break;;
        P) do P stuff;;
        V) do V stuff;;
        L) do L stuff;;
        G) do G stuff;;
        *) echo "Wrong media Choice; Please try again";;
    esac
done

Hey Wempy, when i use your script i am getting an error

tr.sh[3]: 1: not found.

2nd thing, i forgot to mention that this loop should continuw till the operator enters right option.

Hi, yes, er smallish error there replace the "while 1" with "while true". sorry, that was an odd mixture of C and BASH.
shuffles off, muttering I must try harder .....

Its working, thanx for your help buddy, but i think i will come to you again because i m not able to incorporate the script in my old script. Lets see, Will inform u by day end. :slight_smile:

its always a better practice to use

while :

instead of

while true 

hey buddy, it working perfectly, but as soon as an operator enters correct option, the script should come out of loop, instead of that it continues to ask for option except when operator enters "Q".

use

break

command once the operation in each option is done