Hi There
I have to wrote a script where I am able to echo a result of an SQL script, however I want to be able to send an email to myself when it is more than 0 (so whenever a value is returned) is this possible?
I tried one way from looking on the web but this didn't work, I have added my script below:
duplicate_user_list=`psql cemdb admin -t -f /opt/ca/SAP_Tooling/sql/self_monitoring/duplicate_users.sql|sed '/^$/d' | awk '{print $1}'`
duplicate_user_count=`psql cemdb admin -t -f /opt/ca/SAP_Tooling/sql/self_monitoring/duplicate_users.sql|sed '/^$/d' | wc -l`
if [ "$duplicate_user_count" -eq 0 ]
then
duplicate_user_status="No Duplicate IP's Found"
else
duplicate_user_status="Duplicate IP's Found"
fi
if [ "$duplicate_user_count" -gt 1 ]
then
echo "mail sent to SAP Tooling Team" | mail -s "$duplicate_user_list" alex.simpson1@britishgas.co.uk
The count works fine and returns what is expected
Any help will be much appreciated
Many Thanks