Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if condition within case

Status
Not open for further replies.

sandeepmur

Programmer
Dec 14, 2003
295
PT
Hi,

I have the fwg which used to work for sometime but lately giving some errors:

Code:
case $ARG1 in
	's'|'start')
		whatIs $ARG2
		if [ $WHATIS=="sh" ]; then {
		runScript $WHATIS
		} else {
		getCommand $WHATIS
		startCompSpcAll $WHATIS
		} fi

whats wrong in the above code ??

thnx
 
giving some errors
Any chance you could post the whole error message(s) ?
Which shell are you using ?
For Bourne compatible shell, you may try this:
Code:
case $ARG1 in
    s|start)
        whatIs $ARG2
        if [ "$WHATIS" = "sh" ]; then
            runScript $WHATIS
        else {
            getCommand $WHATIS
            startCompSpcAll $WHATIS
        }
        fi
    ;;
esac

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
am using korn shell.

The exact error message is:

/tib/e_v1.sh[1086]: adb: A test command parameter is not valid.

thnx
 
You might want to put a

set -x

before the suspect code, and a

set +x

right after.

Then run the script and look at which command is being run right before the error message.

I would hazard a guess that you need the same trick in the function WhatIs...


HTH,

p5wizard
 
A test command parameter is not valid
As in my suggested code, at least replace this:
if [ $WHATIS=="sh" ]
By this:
if [ "$WHATIS" = "sh" ]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Yes PH, you are right, but I tried to let sandeepmur find this error himself.

Plus, strategically placed set -x/set +x pairs have proven useful to me on numerous occasions...


HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top