[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] Full User List



"Gerald Waugh" <gwaugh@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> It will also send the mail to these users
<snip>
> root
> bin
</snip>

You're right.  Here's how to take care of it.  Create a file
global_email_ignore.txt that looks like this:

adm
bin
chiliasp
daemon
halt
httpd
lp
mail
mailman
mysql
named
news
nobody
pop
postgres
root
shutdown
sync
uucp

Notice I added mailman and mysql.  Add any users you want to ignore.
There's no harm in having users listed that don't actually exist so if you
don't have a mailman or mysql user you can leave them there if you want.

I modified the script I posted last night to ignore the users in the above
file and to ignore users beginning with the text "SITE" since those are
anonymous FTP users.  global_email_ignore.txt should be in the same
directory as the script below.

#!/bin/sh

for i in `cat /etc/passwd | cut -d ":" -f 1`
do
        if [ ! `grep "^$i$" global_email_ignore.txt  || echo $i | grep
^SITE` ]
        then
                mail -s "Subject Here" $i < /path_to/message_body
        fi
done

FYI, I tested the above script and it appears to work properly.  If you want
to test it first change:

mail -s "Subject Here" $i < /path_to/message_body

to:

echo "mail -s "Subject Here" $i < /path_to/message_body"

in order to have it print to the screen the commands it will run instead of
actually running them.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/