The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
help needed for multiline comment deleting script aster007 Shell Programming and Scripting 1 10-10-2008 05:40 AM
How to copy and comment out upsrk Shell Programming and Scripting 3 06-19-2008 11:01 AM
How to put a comment at the begining of the sentence madhusmita Shell Programming and Scripting 1 06-19-2008 03:14 AM
Block Comment in Shell script skyineyes Shell Programming and Scripting 3 07-02-2007 08:15 AM
# comment rocker40 UNIX for Dummies Questions & Answers 6 01-07-2004 12:53 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-19-2008
sparcguy sparcguy is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2006
Posts: 316
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.


Quote:
#!/bin/ksh
export PRISTAT=`/usr/sbin/cmviewcl -v | grep -i current | awk '{ print $3 }'`
export SECSTAT=`/usr/sbin/cmviewcl -v | grep -i alternate | awk '{ print $3 }'`
#
check_switching_mode()
{
# Check Primary node
if [ $PRISTAT!="enabled" ]
then
echo $PRISTAT
echo "cmmodpkg -v -e -n PRIMARY PACKAGE_NAME"
else
echo "switching mode on Primary is already enabled"
fi
# Check Secondary node
if [ $SECSTAT!="enabled" ]
then
echo $SECSTAT
echo "cmmodpkg -v -e -n SECONDARY PACKAGE_NAME"
else
echo "switching mode on Secondary is already enabled"
fi
}
check_switching_mode
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.

Last edited by sparcguy; 11-19-2008 at 11:48 PM..
  #2 (permalink)  
Old 11-20-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,311
Just to make sure, put double brackets around the if tests and write it like following:
Quote:
if [[ $PRISTAT != "enabled" ]]
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.
  #3 (permalink)  
Old 11-20-2008
sparcguy sparcguy is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2006
Posts: 316
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?
  #4 (permalink)  
Old 11-21-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,311
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0