|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
IF THEN ELIF question in BOURNE SHELL
Hi,
I get an error when executing this sample script. #!bin/sh if [ $1 = ]; then echo "you need to enter the release as the first parameter" elif [ $1 = "ALL" ]; then echo "HI how are you ABC" echo "Hi how are you XYZ" echo " hi how are you all" else echo "using the $1 as input parameter" fi i get the following error. [: arun.sh 5: FSUM6807 expression syntax error the script requires a parameter to be passed.. If no parameter is passed the script works fine and it displays the right message. and if the parameter is ALL then also it works fine...i get the above error only if the parameter is other than null or ALL.. how to resolve this...looks like there is a problem with the else statement. |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Change Code:
if [ $1 = ]; to Code:
if [ -z $1 ]; |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Quote:
|
|
#4
|
||||
|
||||
|
Don't forget to quote the variable with -z, otherwise an unset variable will break the script. Code:
if [ -z "$1" ]; |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
It worked
Hi
I tried ur suggetion and it worked. Thanks a lot |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to activate Korn Shell functionnalities in Bourne Shell | madmat | Shell Programming and Scripting | 3 | 03-31-2010 08:41 AM |
| I need to understand the differences between the bash shell and the Bourne shell | awk_sed_hello | Shell Programming and Scripting | 7 | 11-05-2009 04:40 AM |
| simple shell script with elif and for nexxt | locutus01 | Shell Programming and Scripting | 2 | 10-06-2009 06:08 AM |
| Bourne Shell: if elsif question | leostar_10 | Shell Programming and Scripting | 3 | 03-09-2008 07:37 PM |
| bourne shell timing question | gillbates | UNIX for Dummies Questions & Answers | 7 | 02-01-2004 03:44 PM |
|
|