'Unable to read and send the output of the count of table through email
Tried to figure out but could not find much help. I want to capture the count of the table and send an email if the count is more than 0. The output in the email should be as shown below only if it crosses the count more than 0. Please help, thanks in advance for helping me out.
spool log;
SELECT count(*)
FROM users
;
spool off
EOF
count=`grep -rn log | wc -l`
if [ $count != "1" ]
then
cat log | mailx -r [email protected] " ${MAILTO} > /dev/null 2>&1
else
echo "No Sessions found"
fi
Output:
Count(*)
2
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
