Sponsored Content
Top Forums UNIX for Dummies Questions & Answers IF THEN ELIF question in BOURNE SHELL Post 302115015 by arun_st on Friday 20th of April 2007 05:40:05 AM
Old 04-20-2007
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.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

bourne shell timing question

In one of my scripts I do the following sort +0 x > y mv y x In my script x and y are fully qualified. This works 99% of the time. However once in a while the system comes back and says that is cannot access y in the mv command. I did some research and I suspect that if I insert a... (7 Replies)
Discussion started by: gillbates
7 Replies

2. UNIX for Dummies Questions & Answers

Bourne-again shell

Hi guys !! well i'm still new in learning UNIX , and actually i'm still studying it by myself .. anyway, some people told me the Bourne-again shell is a good version of UNIX to work on , and i tried to download yesterday but i didn't know how to start it ...... the ReadMe file associated with... (3 Replies)
Discussion started by: mrsamer
3 Replies

3. Shell Programming and Scripting

Bourne Shell: if elsif question

Hi All, Must be something obvious I am missing, but the simple script below doesn't work. #!/bin/sh x=4 if then echo "x is $x" elsif then echo "x is greater than 4" else echo "x is less than 4" fi When I run this script, I get the error message: 7: Syntax error... (3 Replies)
Discussion started by: leostar_10
3 Replies

4. Shell Programming and Scripting

simple shell script with elif and for nexxt

Hi! I have here a simple script to change the advskew on carp interfaces. The first is working, but the part for status, where a for is within a if/else delivers everyime only the action for the value "prod". Even when i use type test or dev. Where did i made the mistake? # $Log:... (2 Replies)
Discussion started by: locutus01
2 Replies

5. Shell Programming and Scripting

I need to understand the differences between the bash shell and the Bourne shell

I do not claim to be an expert, but I have done things with scripts that whole teams of folks have said can not be done. Of course they should have said we do not have the intestinal fortitude to git-r-done. I have been using UNIX actually HPUX since 1992. Unfortunately my old computer died and... (7 Replies)
Discussion started by: awk_sed_hello
7 Replies

6. Shell Programming and Scripting

How to activate Korn Shell functionnalities in Bourne Shell

Hi All I have writing a Korn Shell script to execute it on many of our servers. But some servers don't have Korn Shell installed, they use Borne Shell. Some operations like calculation don't work : cat ${file1} | tail -$((${num1}-${num2})) > ${file2} Is it possible to activate Korn Shell... (3 Replies)
Discussion started by: madmat
3 Replies

7. UNIX for Dummies Questions & Answers

Bourne-sh (not bash) question about nested loops and sed

Here's the input: alpha, numeric or alphanumeric string ("line 1 string") numeric string ("line 2 string") numeric string ("line 3 string") numeric string ("line 4 string") ... where - each numeric string is in a pattern that can be matched with RE but - there can be any number of... (2 Replies)
Discussion started by: uiop44
2 Replies

8. Shell Programming and Scripting

Bourne/C shell help

Exercise Five Write a Bourne shell script which: • Professionalism: plan for this from the start. • Has one command line argument. • If the command line argument is a directory then the script should output the number of files in the directory. • If the command line argument is an ordinary... (2 Replies)
Discussion started by: moesom
2 Replies

9. Shell Programming and Scripting

Bourne shell & Korn shell

Could some one tell me the difference btw Bourne shell and the Kshell? Which is more flexible and reliable in terms of portability and efficiency. When i type the following command .. $ echo $SHELL yields me /bin/sh Does this tells me that I am in Bourne shell. If yes, how can i get... (6 Replies)
Discussion started by: bobby1015
6 Replies

10. Cybersecurity

'Shell Shock' vulnerability in Bourne shell

A severe vulnerability was discovered in Bourne shell. Just google for: bash vulnerability ... for more details. (5 Replies)
Discussion started by: Cochise
5 Replies
echo(1B)					     SunOS/BSD Compatibility Package Commands						  echo(1B)

NAME
echo - echo arguments to standard output SYNOPSIS
/usr/ucb/echo [-n] [argument] DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi- ronment variables. For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows: o echo your current-working-directory's full pathname o pipe the output through tr to translate the path's embedded slash-characters into space-characters o pipe that output through wc -w for a count of the names in your path. example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w" See tr(1) and wc(1) for their functionality. The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's echo() also understands a as the audible bell character; however, these commands do not have an -n option. OPTIONS
-n Do not add the NEWLINE to the output. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5) NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases. SunOS 5.11 3 Aug 1994 echo(1B)
All times are GMT -4. The time now is 09:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy