Sponsored Content
Full Discussion: comparing two strings
Top Forums Shell Programming and Scripting comparing two strings Post 302089923 by ragha81 on Thursday 21st of September 2006 11:49:19 AM
Old 09-21-2006
Vgersh, let me tell you what

You are an absolute genius.

I made the changes and I got the output. this is the final code after doing the changes you told

Code:
#!/bin/ksh
#
# Purpose: - Turn on Workflow Monitor agents that are not in 'running'/'online' state

umask 000
export LT=`date +%Y%m%d_%H%M%S`

if [ -f ./WorkflowMon_env.rc ]
then
   . ./WorkflowMon_env.rc
else
   echo "FATAL: Error sourcing Workflow Server Components!" >> error.log
   exit -1
fi

# Obtain the secure username and password (if it exists)
#
if [ -f "$BATCH_USER_DIR/batch_user.ksh" ]
then
   TMPPWD=`pwd`               
   cd $BATCH_USER_DIR         
   . ./batch_user.ksh        
   RTNCD=$?                 
   cd $TMPPWD              
   if [ $RTNCD = 0 ]
   then
      export SIEBEL_USERNAME=$USERID
      export SIEBEL_PASSWORD=$PASSWORD
   else
      echo "FATAL: batch_user.ksh returned an error ($RTNCD)" >> error.log
      exit -1
   fi
else
   echo "ERROR: batch_user.ksh does not exist, unable to source in variables" >> error.log
   exit -1
fi
export temp_output=$BATCH_USER_DIR/WorkflowMon/log/temp_$LT.out
export input_file=$BATCH_USER_DIR/WorkflowMon/scripts/srvrmgr_input
i=0
echo ${#wfname[*]} 
until [ $i -eq ${#wfname[*]} ]
do
   
$SIEBEL_ROOT/bin/srvrmgr -g $SIEBEL_GATEWAY -e $SIEBEL_ENTERPRISE -s $SIEBEL_SERVER -u n9912499 -p n9912499 -c "list component '${wfname[$i]}' show SV_NAME, CC_NAME, CP_DISP_RUN_STATE" -o "$temp_output"  
sed -n "/^SV_NAME/,$ p" < $temp_output | sed "/rows* returned/,$ d" | nawk '
NR > 2 && NF {n = split($0,arr," ")
printf("%s|",arr[1])
for( k = 2; k <=n-1;++k) printf("%s ",arr[k])
printf("\b|%s\n",arr[n]) }' > temp
old_IFS=$IFS
IFS="|"
set -x
while read SV_NAME CC_NAME CP_DISP_RUN_STATE
do
if [ "${wfname[$i]}" != "ALLTEL - WebOrders WorkActn" ]
then
if [ "$CP_DISP_RUN_STATE" != "${status[0]}" ]
then
echo success

fi
elif [ "${wfname[$i]}" = "ALLTEL - WebOrders WorkActn" ] 
then

if [ "$CP_DISP_RUN_STATE" != "${status[1]}" ]
then
echo good
fi
fi
done < temp

 ((i=i+1))
done

I just got 1 success as output as expected
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
echo(1B)					     SunOS/BSD Compatibility Package Commands						  echo(1B)

NAME
echo - echo arguments to standard output SYNOPSIS
/usr/ucb/echo [-n] [argument] DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi- ronment variables. For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows: o echo your current-working-directory's full pathname o pipe the output through tr to translate the path's embedded slash-characters into space-characters o pipe that output through wc -w for a count of the names in your path. example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w" See tr(1) and wc(1) for their functionality. The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's echo() also understands a as the audible bell character; however, these commands do not have an -n option. OPTIONS
-n Do not add the NEWLINE to the output. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5) NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases. SunOS 5.10 3 Aug 1994 echo(1B)
All times are GMT -4. The time now is 04:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy