procmail
[Top] [All Lists]

Re: Deferred delivery to a pager

1998-01-15 17:22:06
David W. Tamkin wrote:



| What I want to achieve is
| send the message onto the pager if the hours are "normal" otherwise, defer
| delivery to the pager until the hours become normal.


| The best method I've seen so far was to copy the message to a temporary
| area and mail that to the pager or defer the mailing via at, if the
| timeframe is inappropriate.



 For those who may be interested in something similar (not extensively tested
yet...):

The .procmailrc end....

:0
* SUBADDR ?? flug
{
        :0c
        | cat - > /usr/users/mike/pager_deferred/page.$$ &&
/usr/users/mike/pager_deferred.sh /usr/users/mike/pager_deferred/page.$$

        :0
        test                            # will go to $MAILDIR/test
}

The shell script end...
#!/bin/sh
#
# defer pager notifications until reasonable times
#
#       (C) mike(_at_)innosoft(_dot_)com January 1998
#
#       Use at own peril, if you dare, but send any updates back to me!
#
#
# This code is used to take a message and
# either deliver it to the pager or defer it until a more "acecptable" time
#
# In the latter case,  delivery is via at
#
CONTROLS=/usr/users/mike/controls.master
THIS_JOB=/usr/users/mike/pager_deferred.sh


# shell function to grab the master parameter
getControlValue() {
 y=`grep $1 $CONTROLS |awk -F= '{print $2}'`
 echo $y
}
MSG=$1

HOUR_NOW=`date +%H`
OFFSET_HOURS=`getControlValue PAGER_DEFERRED_OFFSET_HOURS`
START_HOUR=`getControlValue PAGER_DEFERRED_START_HOUR`
END_HOUR=`getControlValue PAGER_DEFERRED_END_HOUR`
PAGER_ADDRESS=`getControlValue PAGER_ADDRESS`

START_HOUR=`expr $START_HOUR + $OFFSET_HOURS`
END_HOUR=`expr $END_HOUR + $OFFSET_HOURS`


#       if sane hours
if [ $HOUR_NOW -ge $START_HOUR -a \
     $HOUR_NOW -lt $END_HOUR ]
then
    #       get required headers
    #           Trim to 20 chars (S= to ensure readability of overall msg)
    SUBJECT="S=`cat $MSG| formail -x Subject: | cut -c2-20`"
    #           usually this gets us Fred Bloggs from personal name field
    ORIGINATOR="F=`cat $MSG| formail -x From: | awk '{print $1 \" \" $2}'`"
    #           I want to know when it got to me - use filesystem date/time
    DATE="D=`ls -al $MSG | awk '{print $6 $7 \" \" $8}'`"

    echo "$ORIGINATOR"
    echo "$SUBJECT"
    echo "$DATE"
    #       get & format body
    BODY=`cat $MSG | formail -I "" | tr '\012' ' ' |  cut -c1-120 | fold -s -w 
72`

    echo "$BODY"

    #       send
    (echo "$ORIGINATOR, $SUBJECT, $DATE - $BODY" | mail $PAGER_ADDRESS ) && \
    ( sleep 3; rm $MSG)
  else
    #           create at job
    echo "$THIS_JOB $MSG" | at $START_HOUR am
fi


--
 Mike de Laine        Technical Support, Innosoft International, Inc.

        "Each success only buys an admission ticket
        to a more difficult problem" - HAK



<Prev in Thread] Current Thread [Next in Thread>