Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending email if file exists or not in unix script

Status
Not open for further replies.

12bpm

Programmer
Apr 8, 2008
8
IE
this is what i want to get

- IF the gap >= 10 and file /tmp/<dbname>_alert does not exist
THEN
o send an email to create a new case and dispatch to aim_dba

o Create the file /tmp/dbname_alert

If /tmp/<dbname>_alert exists and the gap <=9
? Remove the file /tmp/<dbname>_alert


here is some of my output from the unix script

-----------------------
elif
gap>=10 and /tmp/<dbname> <>exist
then
send_mail
fi
gap<=9 and /tmp exists
then
rm /tmp

-----------------------------
also have a function that shows the gap in delay and sends mail


elif [ ${GAP} -ge ${DELAY} ]; then
SUBJECT="$HOST: ERROR - Standby Database ${ORACLE_SID} is $GAP hours behind"
MESSAGE="`date` CRITICAL ERROR: ${ORACLE_SID} on ${HOST} is $GAP hours behind
, Error Limit is set at ${DELAY} hours, action required"
echo $MESSAGE > ${MESSAGE_FILE}.${ORACLE_SID}
echo "`date` Sending Message File.\n"
send_message
fi
echo
echo "$MESSAGE"
echo
}
anyone got any better way to do this in one function where i send the email if the gap is >=10 and create the file in /tmp
else if gap<9 hours files already exists in TMP and remove it
 
man test

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Have a look at thread822-1441116 - I'm not saying you should have found it using a search - I only remember it because I was involved but it's doing pretty much the same thing.

On the internet no one knows you're a dog

Columb Healy
 
What kind of ideas, the ones mentioned above should be sufficient to do what you require?

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top