Sponsored Content
Full Discussion: Email Alert in UNIX
Top Forums UNIX for Beginners Questions & Answers Email Alert in UNIX Post 302993369 by drysdalk on Thursday 9th of March 2017 08:34:41 AM
Old 03-09-2017
Hi,

I've had to hard-code the variables in this example of course, but something like this should work.

Code:
$ cat script.sh 
#!/bin/bash
duplicate_user_list="rod jane freddy"
duplicate_user_count=3

if [ "$duplicate_user_count" -gt "0" ]
then
        echo "Duplicate users found, mailing you the details"
        echo "$duplicate_user_list" | mail -s "Details of duplicate users" unixforum@localhost
        exit 1
else
        echo "No duplicate users found"
        exit 0
fi

$ ./script.sh 
Duplicate users found, mailing you the details
$ mail
"/var/mail/unixforum": 1 message 1 new
>N   1 unixforum@localhost Thu Mar  9 13:30  15/667   Details of duplicate users
? 1
<Some headers redacted for privacy reasons>
Subject: Details of duplicate users
To: <unixforum@localhost>
X-Mailer: mail (GNU Mailutils 2.99.99)

rod jane freddy
? d 1
? q
Held 0 messages in /var/mail/unixforum
$

Hope this helps.
This User Gave Thanks to drysdalk For This Post:
 

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
CONFLICT(8)							     [nmh-1.5]							       CONFLICT(8)

NAME
conflict - search for alias/password conflicts SYNOPSIS
/usr/lib/mh/conflict [-search directory] [-mail name] [-version] [-help] [aliasfiles ...] DESCRIPTION
Conflict is a program that checks to see if the interface between nmh and the transport system is in good shape Conflict also checks for maildrops in /var/mail which do not belong to a valid user. It assumes that no user name will start with `.', and thus ignores files in /var/mail which begin with `.'. It also checks for entries in the group(5) file which do not belong to a valid user, and for users who do not have a valid group number. In addition duplicate users and groups are noted. If the -mail name switch is used, then the results will be sent to the specified name. Otherwise, the results are sent to the standard output. The -search directory switch can be used to search directories other than /var/mail and to report anomalies in those directories. The -search directory switch can appear more than one time in an invocation to conflict. Conflict should be run under cron(8), or whenever system accounting takes place. FILES
/etc/nmh/mts.conf nmh mts configuration file /etc/passwd List of users /etc/group List of groups /usr/bin/mh/mhmail Program to send mail /var/mail/ Directory of mail drop PROFILE COMPONENTS
None SEE ALSO
mh-alias(5) DEFAULTS
`aliasfiles' defaults to /etc/nmh/MailAliases CONTEXT
None MH.6.8 11 June 2012 CONFLICT(8)
All times are GMT -4. The time now is 02:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy