Sponsored Content
Full Discussion: Email Alert in UNIX
Top Forums UNIX for Beginners Questions & Answers Email Alert in UNIX Post 302993366 by simpsa27 on Thursday 9th of March 2017 08:03:43 AM
Old 03-09-2017
Email Alert in UNIX

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

Code:
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 0 ]
 then
 echo "mail sent to SAP Tooling Team" | mail -s "$duplicate_user_list" dummyuser@dummydomain.co.uk

The count works fine and returns what is expected

Any help will be much appreciated

Many Thanks



Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!
For your benefit, I replaced your clear text e-mail-address with a dummy one.

Last edited by RudiC; 03-09-2017 at 10:23 AM.. Reason: Added CODE tags.
 

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Email alert script

I need to code a script, which will run via cron, every 30 minutes. The script will read a file containing a date&time and number (which represents disk space). The file gets appended to every 30 minutes. Here's a sample of the file: CPU 1:04/25/02 1:00 am:1972554 CPU 1:04/25/02 1:30... (1 Reply)
Discussion started by: moon
1 Replies

2. Shell Programming and Scripting

email Alert

Hello, I want a script that will scan the file /etc/httpd/conf/httpd.conf and the folder /etc/httpd/libexec/ -bash-2.05b# grep mod_r /etc/httpd/conf/httpd.conf LoadModule rewrite_module libexec/mod_rewrite.so AddModule mod_rewrite.c -bash-2.05b# -bash-2.05b# find... (4 Replies)
Discussion started by: fed.linuxgossip
4 Replies

3. Shell Programming and Scripting

Unix Shell Script to automate email alert

Hi all, I have a task on my plate which is of high priority. I need an automated email alert that checks FTP notices subdirectory on a daily basis and forwards any word files to a group of people. This word files gets created whenever there is an issue with FTP connectivity. Please help...... (1 Reply)
Discussion started by: stunnerz_84
1 Replies

4. Shell Programming and Scripting

Using top command to email if process is exceeding 25% and sending an email alert if so

This is my first time writing a script and Im having some trouble, Im trying to use the top command to monitor processes and the amount of CPU usage they require, my aim is to get an email if a process takes over a certain percentage of CPU usage I tried grep Obviosly that hasnt worked, Any... (8 Replies)
Discussion started by: jay02
8 Replies

5. Shell Programming and Scripting

Email alert after termination

I am running the gaussian program on UNIX with bash and I want to form a script that will email me once the output life terminates either "normal termination" or "false" I just started learning this last week so could you let me know how to go about this.:b: (13 Replies)
Discussion started by: Jade_Michael
13 Replies
BASHBUG(1)						      General Commands Manual							BASHBUG(1)

NAME
bashbug - report a bug in bash SYNOPSIS
bashbug [--version] [--help] [email-address] DESCRIPTION
bashbug is a shell script to help the user compose and mail bug reports concerning bash in a standard format. bashbug invokes the editor specified by the environment variable EDITOR on a temporary copy of the bug report format outline. The user must fill in the appropriate fields and exit the editor. bashbug then mails the completed report to bug-bash@gnu.org, or email-address. If the report cannot be mailed, it is saved in the file dead.bashbug in the invoking user's home directory. The bug report format outline consists of several sections. The first section provides information about the machine, operating system, the bash version, and the compilation environment. The second section should be filled in with a description of the bug. The third sec- tion should be a description of how to reproduce the bug. The optional fourth section is for a proposed fix. Fixes are encouraged. ENVIRONMENT
bashbug will utilize the following environment variables if they exist: EDITOR Specifies the preferred editor. If EDITOR is not set, bashbug defaults to emacs. HOME Directory in which the failed bug report is saved if the mail fails. TMPDIR Directory in which to create temporary files and directories. SEE ALSO
bash(1) AUTHORS
Brian Fox, Free Software Foundation bfox@gnu.org Chet Ramey, Case Western Reserve University chet@po.cwru.edu GNU Bash-4.0 1998 July 30 BASHBUG(1)
All times are GMT -4. The time now is 05:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy