condition1 -a condition2
True if both condition1 and condition2 are true.
The -a binary primary is left associative and has
higher precedence than the -o binary primary.
condition1 -o condition2
True if either condition1 or condition2 is true.
The -o binary primary is left associative.
The problem is actually with the loop. The condition is working fine. In this code when the condition satisifies it has to give output an output like this
sble01
ALLTEL - WebOrders WorkMon Shutting
down
success
sble01
ALLTEL WorkMon24Hrs
Running
but it is giving output as below
sble01
ALLTEL - WebOrders WorkMon Shutting
down
success
success <----------------This shouldnt appear here
sble01
ALLTEL WorkMon24Hrs
Running
pls see the code and find out the error
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" | awk '
NR > 2 {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="|"
while read SV_NAME CC_NAME CP_DISP_RUN_STATE
do
echo $SV_NAME
echo $CC_NAME
echo $CP_DISP_RUN_STATE
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 really don't have much time to debug tthis, but you could start [as suggested] by putting the 'set -x' at the top of your script and see what gets executed and how things get 'compared'.
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'.
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.
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>
the problem is not with comparison as I initially thought. thanks for your reply. the problem appears with the code. can you look at the code and tell me what the problem could be. thanks