comparing two strings


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting comparing two strings
# 8  
Old 09-20-2006
this looks like your problem:
Code:
+ read SV_NAME CC_NAME CP_DISP_RUN_STATE
+ echo

+ echo
+ echo

+ [ ALLTEL WorkMon24Hrs != ALLTEL - WebOrders WorkActn ]
+ [  != Running ]
+ echo success
success

seems like none of the variables in green got 'read' - their 'echo-s' [and therefore values are 'empty'.
therefore your 'if-s' succeed outputing 'sucess'.
# 9  
Old 09-20-2006
Can you help me rectify that. I have no idea as to how to solve that..
# 10  
Old 09-20-2006
Quote:
Originally Posted by ragha81
Can you help me rectify that. I have no idea as to how to solve that..
you have to make sure that whatever the 'read' statement reads in are valid value that you later on do comparison on.

looking at it for 1 minute, it looks like you're READing a 'blank' line whereas you're expecting at least THREE fields separated by '|'.
# 11  
Old 09-20-2006
I actually have to read the line next to the blank line. how do i modify my code for that. sorry for the trouble. i am new to shell scripts.

the READ part was done by somebody else.

thanks
# 12  
Old 09-20-2006
My log file looks like below. I am actually reading the values from this file. I have to extract the values under SV_NAME, CC_NAME and CP_DISP_RUN_STATE in a variable and use that for comparison. pls help when you find some time.


Code:
Siebel Enterprise Applications Siebel Server Manager, Version 7.5.3.12 [16272] LANG_INDEPENDENT 
Copyright (c) 2001 Siebel Systems, Inc.  All rights reserved.

This software is the property of Siebel Systems, Inc., 2207 Bridgepointe Parkway,
San Mateo, CA 94404.

User agrees that any use of this software is governed by: (1) the applicable
user limitations and other terms and conditions of the license agreement which
has been entered into with Siebel Systems or its authorized distributors; and
(2) the proprietary and restricted rights notices included in this software.

WARNING: THIS COMPUTER PROGRAM IS PROTECTED BY U.S. AND INTERNATIONAL LAW.
UNAUTHORIZED REPRODUCTION, DISTRIBUTION OR USE OF THIS PROGRAM, OR ANY PORTION
OF IT, MAY RESULT IN SEVERE CIVIL AND CRIMINAL PENALTIES, AND WILL BE
PROSECUTED TO THE MAXIMUM EXTENT POSSIBLE UNDER THE LAW.

If you have received this software in error, please notify Siebel Systems
immediately at (650) 295-5000.

Type "help" for list of commands, "help <topic>" for detailed help

Connected to 1 server(s) out of a total of 1 server(s) in the enterprise

srvrmgr:sble01> list component 'ALLTEL - WebOrders WorkActn' show SV_NAME, CC_NAME, CP_DISP_RUN_STATE

SV_NAME  CC_NAME                      CP_DISP_RUN_STATE  
-------  ---------------------------  -----------------  
sble01   ALLTEL - WebOrders WorkActn  Online             

1 row returned.

srvrmgr:sble01>

# 13  
Old 09-20-2006
a 'quick and durty' fix to a not-so-elegate code....

change
Code:
NR > 2

TO

Code:
NR > 2 && NF

good luck.
# 14  
Old 09-21-2006
if i do what you said. i am getting syntax error like this

Code:
awk: syntax error near line 2
awk: bailing out near line 2

kindly help
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing Strings in ksh88

Hi I tried the following string comparison script in Ksh88 #!/bin/ksh str1='aC' str2='ABC' if then echo "Equal" else echo "Not Equal" fi Though str1 and str2 are not equal the script output says Equal . Please correct me Thanks (2 Replies)
Discussion started by: smile689
2 Replies

2. Shell Programming and Scripting

comparing strings as ints

Hi, So I got his code below. $year is a string of 2010,2011 etc. I guess I want to convert $year to an integer so I can do my if statement to see if the year string is greater than 2010? Or how could I do this? Right now I get a syntax error doing this. if; then do stuff fi (2 Replies)
Discussion started by: vsekvsek
2 Replies

3. UNIX for Dummies Questions & Answers

Strings comparing incorrectly

Hello I'm very new to Linux and shell scripting so I only know basic stuff. I'm making a script with the purpose of finding the longest string or word in a file. Here's what I got so far: #!/bin/bash longest="" for i in $(strings -n $1); do if ] then longest=$i fi done echo $longest... (4 Replies)
Discussion started by: SCB
4 Replies

4. Shell Programming and Scripting

Comparing strings with sed

Input: The the the the Output: not-same same What would be the sed command to do this? (7 Replies)
Discussion started by: cola
7 Replies

5. Shell Programming and Scripting

Comparing strings using nawk

Hello All Please I have got a file called DATE.tex which consist of 01-04-2008_12:00:00 01-04-2005_12:00:00 01-04-2003_12:00:00 01-04-2007_12:00:00 01-04-2002_12:00:00 01-04-2009_12:00:00 I want to use nawk to print out the dates >=01-04-2009_12:00:00 I tried this cat plnt.new |... (6 Replies)
Discussion started by: ganiel24
6 Replies

6. Shell Programming and Scripting

comparing two strings

hi All i am facing prob in comparing two strings that have two word. below is the code snippet. checkValidates="file validates" file3_name="file" if then echo "file" $file3_name "is validated successfully" fi when i run this i get the error as -bash: [: too many arguments ... (1 Reply)
Discussion started by: infyanurag
1 Replies

7. Shell Programming and Scripting

comparing 2 strings

hi i have 2 strings. i want to compare the strings. please help (2 Replies)
Discussion started by: satish@123
2 Replies

8. Shell Programming and Scripting

comparing strings

i have a string in a file which gets repeated number of times like below: rpttxt("abc") . . rpttxt("REP_TITLE") rpttxt("BOS_TITLE") . . . . and so on using awk or grep how can i comapre the string( as the second half keeps varying) and store it in a temporary variable? I am using the... (3 Replies)
Discussion started by: agarwal
3 Replies

9. Shell Programming and Scripting

Comparing Two Strings

Hi All, While I am trying to run below code I Am getting the exception like ./abs.sh: line 102: syntax error near unexpected token `then' ./abs.sh: line 102: ` then' The Code Snippet is: if then cat $file1 | sed -e... (8 Replies)
Discussion started by: Anji
8 Replies

10. UNIX for Advanced & Expert Users

Comparing strings

I have two strings a=Mar22 b=may21 how can I compare them Is this fine if then; . ... else .... fi or if then (2 Replies)
Discussion started by: yakyaj
2 Replies
Login or Register to Ask a Question