Pls comment on my script.

Hi guys, hope you scripting gurus here can help me out, the logic in my script somehow not working the way it should, this script part of a bigger backup script suppose to do some checking on the cluster prior to bringing up the package on MC/SG after backend cloning operation, this portion is suppose to check switching parameter if it is disabled, if so then turn it on with command "cmmodpkg -v -e -n hostname package_name", somehow it's not working. :confused:

when I run it the output is like this
# ./ccc
enabled <<<--- from echo $PRISTAT
cmmodpkg -v -e -n PRIMARY PACKAGE_NAME <<<--- this is wrong output
enabled <<<-- from echo $SECSTAT
cmmodpkg -v -e -n SECONDARY PACKAGE_NAME <<< -- this also wrong output

which is wrong.

the output from cmviewcl
# /usr/sbin/cmviewcl -v | grep -i current | awk '{ print $3 }'
enabled

# /usr/sbin/cmviewcl -v | grep -i alterna | awk '{ print $3 }'
enabled

can somebody pls help me.

Just to make sure, put double brackets around the if tests and write it like following:

Also you can have a " | od -c " following up to the echo on $PRISTAT to make sure there aren't any other characters in there.

wow zaxx, solid man! makes a lot of difference

# ./ccc
switching mode on Primary is already enabled
switching mode on Secondary is already enabled

one thing tho just for me to understand,

what's the difference between the statement

[ $STAT2="running" ]

[[ $PRISTAT != "enabled" ]]

Both are working, my question is does the space around the = makes any difference?

To be honest I don't know nor didn't try out. I always have a blank on each side of the testing operator/sign for better readability.