How to display an error msg?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to display an error msg?
# 1  
Old 10-30-2008
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.
# 2  
Old 10-30-2008
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
# 3  
Old 10-30-2008
Code:
#!/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

# 4  
Old 10-30-2008
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.
# 5  
Old 10-30-2008
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 .....
# 6  
Old 10-30-2008
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. :-)
# 7  
Old 10-30-2008
Quote:
Originally Posted by wempy
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 always a better practice to use
Code:
while :

instead of
Code:
while true

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Error msg

When i run errpt -a, the output was below: --------------------------------------------------------------------------- LABEL: DMPCHK_NOSPACE IDENTIFIER: F89FB899 Date/Time: Tue Jan 17 15:00:02 BEIS Sequence Number: 28998 Machine Id: 0058C0CE4C00 Node Id: ... (2 Replies)
Discussion started by: Ivanku
2 Replies

2. Solaris

Where/What/Howto solve warning/error msg about Kernel patch level?

required Solaris 5.10 Kernel patch 137111-03 required Solaris 5.10 Fibre Channel Device Driver patch 125184-08 I want to know about the descriptions and what the patches will do. I searched www.sun.com (patches/updates) but don't see I am looking for. (1 Reply)
Discussion started by: Y4Net
1 Replies

3. Programming

getting "mi_cmd_var_create: unable to create variable object" error msg

Hi, i am working in C in Fedora Eclipse 3.3.0 with gdb debugger. I am geting segmentation fault with an error message "mi_cmd_var_create: unable to create variable object" on debugging the program. What should I do to solve this problem? rgds, Dona_m (14 Replies)
Discussion started by: dona_m
14 Replies

4. UNIX for Dummies Questions & Answers

connecting to a database through a script...if not give an error msg

Hello , i have a problem in writing the shell script.. i have a script already written n just need to make a change in which when the script is not able to connect to the database ..it should print an error msg on the screen. I have already seen previous posts on how to connect to the... (3 Replies)
Discussion started by: sommer_queen
3 Replies

5. Shell Programming and Scripting

Re-direct the error msg to log file

Hi All, I have an expression as follows:- a=`expr ${i} + ${j}` >> $log_file 2>&1 Here, if any of the values i or j or both happens to be empty then the "expr" returns error as "expr: 0402-050 Syntax error." My problem is I am not able to re-direct this error to the log file. Its is getting... (4 Replies)
Discussion started by: rony_daniel
4 Replies

6. Shell Programming and Scripting

Need to capture ERROR msg and stack trace

Hi all, I was hoping someone can point me in the right direction. I'm trying to filter out errors from a web log- any lines with ERROR in it. I know I could simply use the grep command to do this. However, there are times when a stack trace follows the error line. I would like to capture these... (2 Replies)
Discussion started by: gswhoops
2 Replies

7. Linux

Pop error msg

mit@mydomain.com here is the latest error message: There was a problem logging onto your mail server. Your Password was rejected. Account: 'mit@mydomain.com', Server: 'mail.mit.com', Protocol: POP3, Server Response: '-ERR Logon failure: unknown user name or bad password.', Port: 110,... (2 Replies)
Discussion started by: naik_mit
2 Replies

8. HP-UX

Sending Error msg from HP-UX to E-mail address

Sometimes, for any reason, the UX System sends messages to /var/mail/root and/or to Error Log of the guardian. I'll appreciating if you help me to configure so that those messages are also sent to the System Administrator's e-mail address. Regards Gege (1 Reply)
Discussion started by: cgege
1 Replies

9. UNIX for Dummies Questions & Answers

Error msg displayed in SCO server

hi all The following error msg was displayed in the sco server 5.0.5. can anybody explain what it is? "WATCHDOG REINITMEMORY 6 FOR BOARD" replies appreciated. raguram R (3 Replies)
Discussion started by: raguramtgr
3 Replies

10. UNIX for Advanced & Expert Users

unix ftp error msg help

we have two alpha stations which are connected on two sides on the same wan (64k leased line), here is one problem described as follow. when i do a ftp to copy a file form one to another, an error mesg shown and the file lenth is 0 at last. diamond> ftp 192.168.50.1 Connected to... (1 Reply)
Discussion started by: royxiao
1 Replies
Login or Register to Ask a Question