LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-26-2007, 05:31 PM   #1
sharathkv
Member
 
Registered: Jul 2003
Distribution: HP-UX
Posts: 35

Rep: Reputation: 15
compare strings in ksh


how come this s*** is not working 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
 
Old 04-26-2007, 10:56 PM   #2
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 718

Rep: Reputation: 72
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
 
Old 04-26-2007, 11:02 PM   #3
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
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.
 
Old 05-01-2007, 05:46 AM   #4
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,287

Rep: Reputation: 173Reputation: 173
works for me too :-/
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Howto compare two strings in C daYz Programming 20 03-04-2007 04:10 AM
Shell script to compare blocks of strings? bruno buys Programming 10 04-15-2006 02:16 PM
[C]How to compare two strings w/o using strcmp() kponenation Programming 22 11-23-2005 08:29 AM
how to find duplicate strings in vertical column of strings markhod Programming 7 11-02-2005 04:04 AM
How to compare these two strings in one line code? powerplane Programming 4 07-10-2003 12:09 AM


All times are GMT -5. The time now is 09:39 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration