Don't do it if flag found.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Don't do it if flag found.
# 1  
Old 10-11-2011
Don't do it if flag found.

Hello people,

I have the below script:

Code:
#!/bin/sh
#gg_alert_info_all.sh

export ORACLE_SID=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export GGS_HOME=$ORACLE_BASE/product/ggs
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$PATH:$ORACLE_HOME/bin:.

SERVER_NAME=`uname -n`
RECEIPIENT=name@company.com
SCRIPT_DIR=/home/oracle/scripts

${SCRIPT_DIR}/gg_info_all.sh > /tmp/msg1$$


grep -q STOPPED /tmp/msg1$$
if [ $? -eq 0 ]
then
mailx -s "GOLDEN GATE PROCESS ABENDED ON $SERVER_NAME" $RECEIPIENT < /tmp/msg1$$
fi

rm /tmp/msg1$$

exit

It basically mails a message if the world STOPPED is found.
Since I want to schedule it at regular intervals, I need some help to add a flag, in order to avoid resending email.
Ideally the flag should be removed if the word STOPPED is not found anymore, therefore the alert will be reactivated.

Thank you in advance.
# 2  
Old 10-11-2011
So basically you want to send the mail again only after STOPPED is not found and then found again?
# 3  
Old 10-11-2011
Hello,
I want ti send the mail ONCE if STOPPED is found and then create a flag that will block from sending email.
Then if no STOPPED is found delete the flag, so in the next STOPPED found the mail will be sent again.
Hope I described it clear :-)
# 4  
Old 10-11-2011
See if this works for you:
Code:
grep -q STOPPED /tmp/msg1$$
if [[ $? -eq 0 ]]; then
  if [[ ! -f Found_Stopped ]]; then
    mailx -s "GOLDEN GATE PROCESS ABENDED ON $SERVER_NAME" $RECEIPIENT < /tmp/msg1$$
    touch Found_Stopped
  fi
else
  rm -f Found_Stopped
fi

This User Gave Thanks to Shell_Life For This Post:
# 5  
Old 10-12-2011
Perfect !

Thank you . I can use this in my various alert scripts.

Last edited by drbiloukos; 10-12-2011 at 04:36 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

In shell scripting found "\n-" and don't know what is it for

Working on UNIX shell scripting I found in env file the following export H1="\n- " echo "${H1} Waiting for dependencies of ${MONITOR_KEY} to be satisfied ..." >> ${LOG} What is in shell \n- The new line character? Thanks for contribution (2 Replies)
Discussion started by: digioleg54
2 Replies

2. UNIX for Dummies Questions & Answers

Get the id with specify flag

.... means multi line ddd,bug fgdrg dfdfsdfdfsd fsdfdfdfd fdfdsfdsfsd ....... flag2 ...... aaa,bug sfsfsfsfs dfdfsdfdfsd fsdfdfdfd fdfdsfdsfsd ...... flag1 ...... ddd,bug fgdrg dfdfsdfdfsd (9 Replies)
Discussion started by: yanglei_fage
9 Replies

3. UNIX for Dummies Questions & Answers

'h' flag in du

Hey, all! Why is the "human readable" flag changing the behavior of du? And while I'm at it, can you make du only look at files, not directories. I often find myself wanting to find the largest file(s) in a dir or vol. Using 'find' itself, it seems you have to at least be able to guess the size of... (2 Replies)
Discussion started by: sudon't
2 Replies

4. AIX

Flag issue

Hi all, We dont have access to aix source code and i have a doubt. The flag SC_NO_RESERVE, is it got to do anything with the failover? If the flag is set the paths are going to failed state. If flag is not set everything comes up fine after failover. Thanks in advance for helping ... (2 Replies)
Discussion started by: gnakul
2 Replies

5. Shell Programming and Scripting

Add the flag

#!/bin/bash while : do ./abc.sh PB sleep 60 ./abc.sh RA sleep 60 ./abc.sh GS sleep 68400 done Instead of making the script sleep for sometime, it doesn't work all the time as time may shift over a period. How to make a script wake up every 30 seconds and check the current time, if... (2 Replies)
Discussion started by: sandy1028
2 Replies

6. AIX

du flag -x

Hi, I would like to know if there's any option to use with the du command so that I can list only the files/directories on the current filesystem... I usually use du -gs *But I'd like to see only the directories in the filesystem I am on, and not the mount point directory of other fss... ... (6 Replies)
Discussion started by: Casey
6 Replies

7. Shell Programming and Scripting

the flag -c in sh command

I need your help please. In a production system, i've seen many running process as follow: sh -c ./pathname/shellname what exactly the flag option -c is used for? ive tried to look at the man page, but it doesnt say much. ill appreciate yor help. Thanks (4 Replies)
Discussion started by: alexcol
4 Replies

8. Shell Programming and Scripting

how can i check in csh if command found or not found ?

hello all im trying to use in sun Solaris the information received from the top command now i several machines that dont have install the top program so when im running the script im geting error saying after im running this code : set MemoryInfo = `top | grep Memory` if (... (2 Replies)
Discussion started by: umen
2 Replies
Login or Register to Ask a Question