procmail
[Top] [All Lists]

working with variables

1999-11-22 09:47:36
Continuing with what I've been working on for a couple of days, I have
now succeeded in making procmail set $DOM to any of six TLDs (five of
which are virtual "satellite" domains and get forwarded to the main
one).

So assuming that $DOM is any of 

        main
        sat1
        sat2
        sat3
        sat4
        sat5

I now get to an auto-reply recipe and want to set the From: and a few
other things using formail.  Suppose the domain that I want to answer
for is "sat1".  I want (numbers added down the left margin for
reference):

0    :0 hi  # i says we don't care about piping the actual text
1     | ( formail -r -I"From:                              \
2         Auto-Reply Daemon <${DOM}bot(_at_)satellite1(_dot_)com>"    \
3        -I"Reply-To: Administrator <admin(_at_)satellite1(_dot_)com>"\
4        -I"Subject: $SUBJ: succeeded!"                    \
5        -A"Precedence: junk"                              \
6        -A"X-Loop: ${DOM}bot"                            ;\
7         echo "$SUBJ: succeded!"                         ;\
8         echo ""; echo "-- "                             ;\
9         echo "<admin(_at_)satellite1(_dot_)com>" ) | $SENDMAIL $SENDMAILFLAGS 
-t


The problem is with lines 2, 3, 6, and 9.  I need to have a second
variable set to accompany $DOM.  $DOM is the short-hand nickname and
will go in lines 2 and 6.  (Do I need to do something special to
allow use of a variable at this place in the recipe?)  But I also
need, e.g., $DOMAIN, figured out somewhere earlier so that it can
replace "satellite1.com" in lines 2, 3, and 9.  I have no idea how to
do this.

In sh I would write something like


    case "$DOM" in
      sat1)  DOMAIN=satellite1.com ;; 
      sat2)  DOMAIN=satellite2.com ;;
      sat3)  DOMAIN=satellite3.com ;;
      sat4)  DOMAIN=satellite4.com ;;
      sat5)  DOMAIN=satellite5.com ;;
      *)     DOMAIN=maindomain.com ;;
    esac

How can I do this inside of procmail?

-- 
    \     .-.     .-.     .-.     .-.     .-.     .-.     .-.     /
     \-d-/-m-\-a-/-n-\-(_at_)-/-n-\-e-/-t-\-c-/-o-\-m-/-.-\-c-/-o-\-m-/
      '-'     '-'     '-'     '-'     '-'     '-'     '-'     '-'

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