[nycbug-talk] CLI mailing from FreeBSD 6.0 Release Question

Mikel King mikel.king
Thu Mar 2 11:48:44 EST 2006


On Mar 1, 2006, at 10:09 PM, Kevin Reiter wrote:

> Hey all,
>
> I'm trying to script an automagic e-mail alert thingy, and it works
> except when actually sending the e-mail.  Here's the part of the  
> script
> that kicks off the e-mail:
>
> mutt -s "Home IP Update" alerts at unixfun.net < temp_ip.log
>
> I then check my e-mail, and nada.  When I check the current procs,  
> I see
> this (and it runs until I kill it):
>
> kevin at chronos$ ps wax | grep unixfun.net
> 78000  ??  Ss     0:00.00 sendmail: ./k2228Lt9077998 mx.unixfun.net.:
> user open (sendmail)
>
> When I check /var/log/maillog, I see this:
>
> Mar  1 22:01:29 chronos sm-mta[78102]: k221Q93t043799:
> to=<alerts at unixfun.net>, ctladdr=<kevin at chronos.unixfun.net>
> (1001/1001), delay=01:35:20, xdelay=00:00:00, mailer=esmtp,  
> pri=390508,
> relay=mx.unixfun.net., dsn=4.0.0, stat=Deferred: Operation timed out
> with mx.unixfun.net.
> Mar  1 22:01:29 chronos sm-mta[78102]: k221LZJc043754:
> to=<alerts at unixfun.net>, ctladdr=<kevin at chronos.unixfun.net>
> (1001/1001), delay=01:39:54, xdelay=00:00:00, mailer=esmtp,  
> pri=390508,
> relay=mx.unixfun.net., dsn=4.0.0, stat=Deferred: Operation timed out
> with mx.unixfun.net.
>
> I was originally using the built-in "mail" command:
>
> cat temp_ip.log | mail -v -s "Home IP Update" alerts at unixfun.net
>
> but that wasn't working either.
>
> This box is only running the standard (non-configured) sendmail.
>
> Is there a setting I need to configure somewhere for the outgoing mail
> server (using either mutt or mail)?
>
> Thanks,
> Kev

Hi Kevin,

	Here's some old silly shell scripting I used to use to do the same  
kind of thing. Basically automagickally send myself log snaps, config  
files, and just about any other message I needed using the page  
script. I used to keep a stack of canned messages for cetain types of  
events like server reboots or make world type ops that I'd use with  
the alarm script.

	I had planned on doing a bunch of other stuff with it but you know  
how spare time goes...;-) I haven't had the chance to test them under  
6.0 yet. If you do let me know.

ALARM:
#!/bin/bash
#
# $Id: alarm.sh,v 1.1 2000/09/08 20:06:52 mikel Exp $
#
# by: Mikel King  (mikel.king at upan.org)
#
# send a predefined message to someone
#
# This is a good utility to had laying around where you'd like a
# predefined set of circumstances initiate some sort of alarm. For
# instance on our system whenever it reboots it automatically lets
# someone know.
#
# Put the message you wish to send in the src directory and then use
# the following line in you trigger script:
#
# alarm msg 2>1 | /usr/sbin/sendmail mailid
#
#
#
# usage: alarm { msg file }
#
# There is a companion utility for use with alarm called: page
#

SRC="/usr/local/etc/msgs"
NOTE="Warning"

usage () {
     echo "usage: $0 <msgfile>" 1>&2
     exit 1
}

if [ $# -lt 1 ] ; then
     usage
fi

if [ $# -eq 2 ] ; then
     SRC=$2

fi

if [ ! -f $SRC/$1 ] ; then
         echo "$1; file specified does not exist in default." 1>&2
         exit 1
else
         MSGFILE="$SRC/$1"

fi

if [ $# -eq 2 ] ; then
     NOTE=$MSGFILE

fi


host=`hostname`
echo "Subject: $NOTE from $HOSTNAME"
cat $MSGFILE


PAGE:
#!/bin/bash
#
# $Id: page.sh,v 1.1 2000/09/08 20:06:52 mikel Exp $
#
# by: Mikel King  (mikel.king at upan.org)
#
# This is companion front end utility for alarm. It can be used
# to circumvent the default behavior of alarm which is to send canned
# predefined system messages to a mailid.  This is the pinnacle of the
# reboot alarm pager messaging system.
#
# This implimentation let's you send a different text file
# to a mail id.
#
#       usage:          page mailid messagefile
#         OR
# circumvent mode:      page mailid filename [file path]
#
# The canned messagefiles reside in /usr/local/etc/msgs
#

SENDCMD=/usr/local/sbin/sendmail
FROM=Charlie.Root at ocsinternet.com
alarm $2 $3 2>&1 | ${SENDCMD} -F ${FROM} $1



Cheers,
Mikel King
Optimized Computer Solutions, INC
Tech Alliance, INC
39 West Fourteenth Street
Second Floor
New York, NY 10011
http://www.ocsny.com
http://www.techally.com
t: 212.727.2100x132
+------------------------------------------+
How do you spell cooperation? Pessimists use
each other, but optimists help each other.
Collaboration feeds your spirit, while
competition only stokes your ego. You'll
find the best way to get along.
+------------------------------------------+






More information about the talk mailing list