LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   compare strings in ksh (http://www.linuxquestions.org/questions/programming-9/compare-strings-in-ksh-549301/)

sharathkv 04-26-2007 05:31 PM

compare strings in ksh
 
how come this s*** is not working :mad: in ksh

Code:


echo "Schema status is : " $tmp_status
if [[ $tmp_status = "ERROR:" ]];
then
  echo "ERROR: schema not available. Please create the schema."
  SCHEMA_MISSING=1
fi

debug mode:

+ echo Schema status is :  Name
Schema status is :  Name
+ [ Name = ERROR: ]
ERROR: schema not available. Please create the schema.

How can "Name" and "ERROR:" be equal??

thanks

makyo 04-26-2007 10:56 PM

Hi.

I created a complete script of the fragment, like so:
Code:

#!/bin/ksh

# @(#) s1      Demonstrate string comparison.

echo
echo " ksh version is $KSH_VERSION"

echo
tmp_status=Name
echo "Schema status is : " $tmp_status
if [[ $tmp_status = "ERROR:" ]];
then
  echo "ERROR: schema not available. Please create the schema."
  SCHEMA_MISSING=1
else
        echo "FAILED: tmp_status is :$tmp_status:"
fi

exit 0

which produces:
Code:

% ./s1

 ksh version is @(#)PD KSH v5.2.14 99/07/13.2

Schema status is :  Name
FAILED: tmp_status is :Name:

Perhaps I missed something, because this is how I expected it to run ... cheers, makyo

wjevans_7d1@yahoo.co 04-26-2007 11:02 PM

I did the same thing, slightly simplified:

Code:

#!/bin/ksh

export tmp_status="Name"

echo "Schema status is : " $tmp_status
if [[ $tmp_status = "ERROR:" ]];
then
  echo "ERROR: schema not available. Please create the schema."
  SCHEMA_MISSING=1
fi

and my output was:

Code:

Schema status is :  Name
Looks ok to me.

bigearsbilly 05-01-2007 05:46 AM

works for me too :-/


All times are GMT -5. The time now is 08:45 PM.