i have written below script, and out put i am looking for both variable PRIMARY_CONF and $STANDBY_CONF but i am getting below error
d1.sh: line 64: [: too many arguments
There is Eroro
------------------------------
line 64 is:
if [ "$PRIMARY_CONF " = "PRIMARY "] -a [ "$STANDBY_CONF " ="PRIMARY " ]; then
----------------------------------
please let me know where is the correction, as i am looking to met both using -a and condition
CURRENT_PRIM=ABC
CURRENT_COB=XYX
ECHO
PRIMARY_CONF=`srvctl config -d $CURRENT_PRIM | awk -F: '/^Database role/ {match ($0, /[A-Za-z_]*PRIMARY[A-Za-z_]*/); print substr ($
0, RSTART, RLENGTH)}'`
echo $PRIMARY_CONF
echo
STANDBY_CONF=`srvctl config database -d $CURRENT_COB | awk -F: '/^Database role/ {match ($0, /[A-Za-z_]*PRIMARY[A-Za-z_]*/); print su
bstr ($0, RSTART, RLENGTH)}'`
echo $STANDBY_CONF
if [ "$PRIMARY_CONF " = "PRIMARY "] -a [ "$STANDBY_CONF " ="PRIMARY " ]; then
echo "Modified the DB $CURRENT_PRIM to $PRIMARY_CONF in cluster level but it will change after Datbase bounce During the SWITCHOVER
Activty"
echo "Modified the DB $CURRENT_COB to $STANDBY_CONF in cluster level but it will change after Datbase bounce During the SWITCHOVER
Activty"
else
echo "There is ERROR"
exit
Thank Rudic, that space issue is resolved, i have other issue now
Note:
CURRENT_PRIM is on node 1 CURRENT_COB is on node 2
here i am trying to get values into below variable from node 1 and node 2 PRIMARY_CONF from node 1 and STANDBY_CONF from node 2
i updated with script
set -x --to check the issue, so here i can see it is not taking values in STANDBY_CONF from if condition from scrip
below i got issue
+ '[' 'PRIMARY ' = 'PRIMARY ' -a ' ' = 'PRIMARY ' ']'
+ echo 'There is Eroro'
There is Eroro
+ exit
======================
please help.....
below is script
CURRENT_PRIM=ABC
CURRENT_COB=XYX
PRIMARY_CONF=`srvctl config database -d $CURRENT_PRIM | awk -F: '/^Database role/ {match ($0, /[A-Za-z_]*PRIMARY[A-Za-z_]*/); print substr ($0, RSTART, RLENGTH)}'`
echo $PRIMARY_CONF
#######CURRENT_COB this DB lies node 2 and in node 1 is CURRENT_PRIM DB is there
echo "Enter the COB Hostname"
read "COB_HOST"
echo
echo "Connenting to COB HOST $COB_HOST"
ssh $COB_HOST << EOF
STANDBY_CONF=`srvctl config database -d $CURRENT_COB | awk -F: '/^Database role/ {match ($0, /[A-Za-z_]*PRIMARY[A-Za-z_]*/); print substr ($0, RSTART, RLENGTH)}'`
echo $STANDBY_CONF
#EOF
if [ "$PRIMARY_CONF " = "PRIMARY " -a "$STANDBY_CONF " = "PRIMARY " ]; then
echo "Modified the DB $CURRENT_PRIM to $PRIMARY_CONF in cluster level but it will change after Datbase bounce During the SWITCHOVER Activty"echo "Modified the DB $CURRENT_COB to $STANDBY_CONF in cluster level but it will change after Datbase bounce During the SWITCHOVER Activty"
else
echo "There is Eroro"
exit
fi
I think your set -x gives pretty clear idea that "srvctl config database...." is not having any output. So $STANDBY_CONF is empty.
May be you want to check by running this command directly on command line and see why it's not showing any output.
srvctl config database -d $CURRENT_COB ---(which need to get output from node2 )
but i fire directly on node2 srvctl config database -d XYX ---- i am getting the output as below
PRIMARY
it is passing variable of $PRIMARY_CONF and but the not the $STANDBY_CONF
in the script it is passing the empty value in $STANDBY_CONF
You are setting PRIMARY_CONF in your shell script and your script is seeing the value that you are setting. You are setting STANDBY_CONF in a shell that you are running on COB_HOST ; not in the shell execution environment of your script. Therefore, STANDBY_CONF has not been set in the current shell execution environment of your script.
i have updated this, but still i am getting same error,
STANDBY_CONF=$(ssh $COB_HOST << EOF
srvctl config database -d $CURRENT_COB | awk -F: '/^Database role/ {match ($0, /[A-Za-z_]*PRIMARY[A-Za-z_]*/); print substr ($0, RSTA
RT, RLENGTH)}'
EOF
)
if [ "$PRIMARY_CONF " = "PRIMARY " -a "$STANDBY_CONF " = "PRIMARY " ]; then
echo "Modified the DB $CURRENT_PRIM to $PRIMARY_CONF in cluster level but it will change after Datbase bounce During the SWITCHOVER
Activty"
echo "Modified the DB $CURRENT_COB to $STANDBY_CONF in cluster level but it will change after Datbase bounce During the SWITCHOVER
Activty"
else
echo "There is Eroro"
exit
fi
==========================
still it is passing variable of $PRIMARY_CONF and but the not the $STANDBY_CONF
in the output it is passing the empty value in $STANDBY_CONF
output with
set -x
+ '[' 'PRIMARY ' = 'PRIMARY ' -a ' ' = 'PRIMARY ' ']'
+ echo 'There is Eroro'
There is Eroro
+ exit