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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

K-Shell Problem

Status
Not open for further replies.

nithink

Programmer
Nov 7, 2002
92
US
Hi, I'm using a k-shell script and i'm passing command-line arguments as "devel" or "prod" and it gives the error on line number 44 which is the "if" condition. Can you pls let me know what the error is ?

myfilename.ksh[44]: devel: bad number


if [ $1 -eq "devel" ] -o [ $1 -eq "prod" ]
then
DEVL_ENV=$1
fi

 
I've usually found that when comparing strings, the equals sign should be used instead of -eq

[tt]
if [ "${1}" = "devel" ] -o [ "${1}" = "prod" ]
then
DEVL_ENV=${1}
fi
[/tt]

Untested, as I don't normally do testing like that, I tend to use a lot of [tt]case/esac[/tt]
 
I got it.. I shud have been using "=" rather than -eq That was the error..
 
Thanks very much Chapter11. I didnt see your reply before I posted. Anyway thanks much !
 
You only should have one set of brackets, as in:

if [ $1 -eq "devel" -o $1 -eq "prod" ]

 
Thanks Sampsonr but it doesnt work. As Chapter11 told, for comparing Strings we should be using "equals" sign instead of -eq.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top