199 lines
6.5 KiB
HTML
199 lines
6.5 KiB
HTML
<!--startcut ======================================================= -->
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<html>
|
|
<head>
|
|
<META NAME="generator" CONTENT="lgazmail v1.2J.g">
|
|
<TITLE>The Answer Guy 42: MATCH and Replaceable Parameters in procmail</TITLE>
|
|
</HEAD><BODY BGCOLOR="#FFFFFF" TEXT="#000000"
|
|
LINK="#3366FF" VLINK="#A000A0">
|
|
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
|
<H4>"The Linux Gazette...<I>making Linux just a little more fun!</I>"</H4>
|
|
<P> <hr> <P>
|
|
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
|
<center>
|
|
<H1><A NAME="answer">
|
|
<img src="../../gx/dennis/qbubble.gif" alt="(?)"
|
|
border="0" align="middle">
|
|
<font color="#B03060">The Answer Guy</font>
|
|
<img src="../../gx/dennis/bbubble.gif" alt="(!)"
|
|
border="0" align="middle">
|
|
</A></H1>
|
|
<BR>
|
|
<H4>By James T. Dennis,
|
|
<a href="mailto:linux-questions-only@ssc.com">linux-questions-only@ssc.com</a><BR>
|
|
LinuxCare,
|
|
<A HREF="http://www.linuxcare.com/">http://www.linuxcare.com/</A>
|
|
</H4>
|
|
</center>
|
|
|
|
<p><hr><p>
|
|
<!-- endcut ======================================================= -->
|
|
<!-- begin 7 -->
|
|
<H3 align="left"><img src="../../gx/dennis/qbubble.gif"
|
|
height="50" width="60" alt="(?) " border="0"
|
|
>MATCH and Replaceable Parameters in procmail</H3>
|
|
|
|
|
|
<p><strong>From Nick Moffitt on Sat, 01 May 1999
|
|
</strong></p>
|
|
<!-- ::
|
|
MATCH and Replaceable Parameters in procmail
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
:: -->
|
|
<P><STRONG><IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
|
|
HEIGHT="28" WIDTH="50" BORDER="0"
|
|
>
|
|
So, here's one for the answer guy.
|
|
</STRONG></P>
|
|
<P><STRONG>
|
|
I have a mhonarc user that creates drop points for a mhonarc script to
|
|
walk by every night and process. Thing is, I don't want to have to
|
|
edit the mhonarc user's <tt>.procmailrc</tt> every single time. That is,
|
|
let's say that I have the following:
|
|
</STRONG></P>
|
|
<Pre><STRONG>
|
|
:0:
|
|
* ^Sender: owner-potato-peelers
|
|
spool/potato-peelers
|
|
|
|
:0:
|
|
* ^Sender: owner-onion-skinners
|
|
spool/onion-skinners
|
|
</STRONG></Pre>
|
|
<P><STRONG>
|
|
Is there some way that I can automate this format? e.g.:
|
|
</STRONG></P>
|
|
<Pre><STRONG>
|
|
:0:
|
|
* ^Sender: owner-\([^@]+\)
|
|
spool/$1
|
|
</STRONG></Pre>
|
|
<P><STRONG>
|
|
This likely breaks procmail's own regex syntax, but you get the point.
|
|
"Anything that has an owner-foo Sender header should go to spool/foo."
|
|
</STRONG></P>
|
|
<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
|
|
HEIGHT="28" WIDTH="50" BORDER="0"
|
|
>
|
|
Nick,
|
|
</BLOCKQUOTE>
|
|
<BLOCKQUOTE>
|
|
You have the right idea but, as you've guessed, the
|
|
wrong syntax. The answer is to use the <tt>MATCH</tt> variable
|
|
and the <tt>\/</tt> (fencepost) operator as described in this
|
|
excerpt from the <tt>procmailrc</tt>(5) man page:
|
|
</BLOCKQUOTE>
|
|
|
|
<blockquote><pre> MATCH This variable is assigned to by procmail when-
|
|
ever it is told to extract text from a match-
|
|
ing regular expression. It will contain all
|
|
text matching the regular expression past the
|
|
`\/' token.
|
|
</pre></blockquote>
|
|
<BLOCKQUOTE>
|
|
So, your recipe would look something like:
|
|
</BLOCKQUOTE>
|
|
|
|
<blockquote><pre>:0:
|
|
* ^Sender: owner-\/.*
|
|
spool/$MATCH
|
|
</pre></blockquote>
|
|
<BLOCKQUOTE>
|
|
(though I haven't tested this specifically).
|
|
</BLOCKQUOTE>
|
|
<!-- sig -->
|
|
|
|
<!-- end 7 -->
|
|
<hr width="40%" align="center"
|
|
|
|
<!-- begin 11 -->
|
|
<H3 align="left"><img src="../../gx/dennis/qbubble.gif"
|
|
height="50" width="60" alt="(?) " border="0"
|
|
>procmail and saved variables.</H3>
|
|
|
|
|
|
<p><strong>From Nick Moffitt on Sun, 2 May 1999
|
|
</strong></p>
|
|
<font color="#000066"><em>
|
|
<P><STRONG>
|
|
[Jim Dennis said]
|
|
So, your recipe would look something like:
|
|
</STRONG></P>
|
|
<P><STRONG><BlockQuote><Code>
|
|
<Br>:0:
|
|
<Br>* ^Sender: owner-\/.*
|
|
<Br>spool/$MATCH
|
|
</Code></BlockQuote></STRONG></P>
|
|
<P><STRONG>
|
|
(though I haven't tested this specifically).
|
|
</STRONG></P>
|
|
</em></font>
|
|
<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
|
|
HEIGHT="28" WIDTH="50" BORDER="0"
|
|
>
|
|
I have! It works like a charm.
|
|
</BLOCKQUOTE>
|
|
<!-- end 11 -->
|
|
|
|
|
|
<!--startcut ======================================================= -->
|
|
<P> <hr> <P>
|
|
<H5 align="center"><a href="http://www.linuxgazette.com/copying.html"
|
|
>Copyright ©</a> 1999, James T. Dennis
|
|
<BR>Published in <I>The Linux Gazette</I> Issue 42 June 1999</H5>
|
|
<H6 ALIGN="center">HTML transformation by
|
|
<A HREF="mailto:star@starshine.org">Heather Stern</a> of
|
|
Starshine Techinical Services,
|
|
<A HREF="http://www.starshine.org/">http://www.starshine.org/</A>
|
|
</H6>
|
|
<P> <hr> <P>
|
|
<!-- begin tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::-->
|
|
<TABLE WIDTH="97%"><TR VALIGN="center" ALIGN="center">
|
|
<TD ROWSPAN="4" COLSPAN="1" WIDTH="37%"><A
|
|
HREF="../lg_answer42.html"
|
|
><IMG SRC="../../gx/dennis/answernew.gif"
|
|
ALT="[ Answer Guy Index ]"></A></td>
|
|
<TD WIDTH="10%"><A HREF="1.html">1</A></TD>
|
|
<TD WIDTH="10%"><A HREF="2.html">2</A></TD>
|
|
<TD WIDTH="10%"><A HREF="3.html">3</A></TD>
|
|
<TD WIDTH="10%"><A HREF="4.html">4</A></TD>
|
|
<TD WIDTH="10%"><A HREF="5.html">5</A></TD>
|
|
<TD WIDTH="10%"><A HREF="6.html">6</A></TD>
|
|
</TR><TR VALIGN="center" ALIGN="center">
|
|
<TD><A HREF="7.html">7</A></TD>
|
|
<TD><A HREF="8.html">8</A></TD>
|
|
<TD><A HREF="9.html">9</A></TD>
|
|
<TD><A HREF="10.html">10</A></TD>
|
|
<TD><A HREF="11.html">11</A></TD>
|
|
<TD><A HREF="12.html">12</A></TD>
|
|
</TR><TR VALIGN="center" ALIGN="center">
|
|
<TD><A HREF="13.html">13</A></TD>
|
|
<TD><A HREF="14.html">14</A></TD>
|
|
<TD><A HREF="15.html">15</A></TD>
|
|
<TD><A HREF="16.html">16</A></TD>
|
|
<TD><A HREF="17.html">17</A></TD>
|
|
<TD><A HREF="18.html">18</A></TD>
|
|
</TR><TR VALIGN="center" ALIGN="center">
|
|
<TD><A HREF="19.html">19</A></TD>
|
|
<TD><A HREF="20.html">20</A></TD>
|
|
<TD><A HREF="21.html">21</A></TD>
|
|
<TD><A HREF="22.html">22</A></TD>
|
|
<TD><A HREF="23.html">23</A></TD>
|
|
<TD><A HREF="24.html">24</A></TD>
|
|
</TR></TABLE>
|
|
<!-- end tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::::-->
|
|
<P> <hr> <P>
|
|
<!-- begin lgnav ::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
|
<A HREF="../../index.html"
|
|
><IMG SRC="../../gx/indexnew.gif" ALT="[ Table Of Contents ]"></A>
|
|
<A HREF="/index.html"
|
|
><IMG SRC="../../gx/homenew.gif" ALT="[ Front Page ]"></A>
|
|
<A HREF="../lg_bytes42.html"
|
|
><IMG SRC="../../gx/back2.gif" ALT="[ Previous Section ]"></A>
|
|
<A HREF="../lg_tips42.html"
|
|
><IMG SRC="../../gx/fwd.gif" ALT="[ Next Section ]"></A>
|
|
<!-- end lgnav ::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
|
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
|
|
</BODY></HTML>
|
|
<!--endcut ========================================================= -->
|