Operating System - HP-UX
1835085 Members
3257 Online
110073 Solutions
New Discussion

Please make this script work for me

 
SOLVED
Go to solution
Ragni Singh
Super Advisor

Please make this script work for me

I have posted this several times but this still doesn;t seem to work. Please take a look at this and tell me what am I doing wrong. I'm looking for the start time, end time of my make recovery, put in a table. Then if the make recovery was completed sucessfully, I wonna show the whole row as color green and if it was not sucessful, I need the row to be color red. Any help will be grealty greatly appreciated. I promise not to bother anyone again...


# Declare variables

do

# Get the start time

ssh $i "tail -2 /var/opt/ignite/logs/makrec.log1 2> /dev/null | grep -i 'Started'" > $TMP_PAGE2

echo "
" >> $TMP_PAGE2

# Get the end time - will also use later for COLOR selection

END=$(ssh $i "tail -2 /var/opt/ignite/logs/makrec.log1 2> /dev/null | grep -i 'Completed'")

echo $END >> $TMP_PAGE2

echo "
" >> $TMP_PAGE2
echo "" >> $TMP_PAGE2

# Get the failure code and set the color

FAIL_CODE=$(ssh $i "tail -2 /var/opt/ignite/logs/makrec.log1 2> /dev/null | grep -i 'ended unsucessfully' | tail -1")

case $FAIL_CODE in

"Completed" )
COLOR="GREEN"
;;

"Ended Unsucessfully" )
COLOR="RED"
;;

* )
COLOR="RED"
;;
esac

# Also set the COLOR based on $END

[ $(echo $END | grep -c completed) -eq 1 ] && COLOR="GREEN"

# Build the first column - This is where we set the color

echo "" > $TMP_PAGE1

echo "" >> $TMP_PAGE1
echo "$i
" >> $TMP_PAGE1
echo "" >> $TMP_PAGE1
echo "
" >> $TMP_PAGE1

# Pull it together

cat $TMP_PAGE1 $TMP_PAGE2 >> $PAGE

done

# end the table

echo "" >> $PAGE
echo "" >> $PAGE

#

4 REPLIES 4
Sridhar Bhaskarla
Honored Contributor

Re: Please make this script work for me

Hi Sanman,

We didn't get any feedback from you in the following post

http://forums.itrc.hp.com/cm/QuestionAnswer/1,11866,0x21eac6af36b7d5118ff10090279cd0f9,00.html

You need to replace remsh with ssh and try my solution. Please let us know.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Ragni Singh
Super Advisor

Re: Please make this script work for me

Okay Sri, look slike I made some progress. Now when I run it, I get this error message...

Completed: not found

Any ideas buddy!!!
Sridhar Bhaskarla
Honored Contributor
Solution

Re: Please make this script work for me

Hi,

In the posting, the first line appears like two lines but it is one line. Did you try making it one?.

Try with ksh -x option. You will know where you are getting this completed: not found error. This may be because you are improperly specifying the case statement.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Ragni Singh
Super Advisor

Re: Please make this script work for me

Thanks for all your time. I'll let you know how it works out for me.