Re: Getting xfilter AND delivery to working
Milan Obuch <[email protected]> Thu, 4 Feb 2016 15:03:21 +0100
| Newsgroups | gmane.mail.maildrop |
|---|---|
| Message-ID | <[email protected]> |
On Fri, 05 Feb 2016 00:34:36 +1100 Philip Rhoades <[email protected]> wrote: > Milan, > > On 2016-02-04 20:39, Milan Obuch wrote: > > On Thu, 04 Feb 2016 19:14:24 +1100 > > Philip Rhoades <[email protected]> wrote: > > > >> People, > >> > >> I have this filter: > >> > >> if( /^[TC][[co]:.*tst/ ) > >> { > >> xfilter "/home/phil/bin/bash_internal_variables.sh > >> > /home/phil/t" to $DEFAULT/.tst/ > >> } > >> > >> and the xfilter is working but the delivery is not - if I reverse > >> the lines, the delivery works but the xfilter does not - how can I > >> get BOTH lines to work? > >> > > > > Hi, > > > > did zou examine your mailogs? Maybe there is a clue... > > No errors or anything unusual . . > > > Also, could you > > show us what's there in /home/phil/bin/bash_internal_variables.sh > > file? > > #!/bin/bash > > echo -n "! | " ; echo $! [ snip ] > echo -n "time | " ; echo $time > > but why should anything in there matter? Even if an error code was > returned, maildrop should still execute the "to" command? > [ snip ] I did some tests and now I can confirm your observation. Here is my explanation. First, quote from 'man maildropfilter': xfilter - filter message through another program xfilter expression expression specifies an external program that maildrop runs to filter the current message. The current message will be piped to the filter program as standard input. The output of the filter program replaces the current message being delivered. The external program must terminate with an exit code of 0. If the external program does not terminate with an exit code of 0, or if it does not read the message from the standard input, maildrop terminates with an exit code of EX_TEMPFAIL. Applied to your example, simplified, line xfilter "/home/phil/bin/bash_internal_variables.sh > /home/phil/t" makes output of command "/home/phil/bin/bash_internal_variables.sh > /home/phil/t" new message content. As your redirected stdout to file, there is no output, which means effectively you deleted the whole message content. Courier sees that and does nothing, as there is nothing to deliver. I think your misused xfilter command. It looks like what you want to do is some environment logging for testing. Try to use backticks, excerpt from the same 'man maildropfilter': Command substitution Text enclosed in back-tick characters is interpreted as a shell command. The shell command is executed as a child process by maildrop. Its output is used in place of the command. For example: DIR=`ls` places the names of the files in the current directory into the DIR variable. The output of the command will have all newline characters replaced by spaces, and leading and trailing spaces will be stripped (multiple spaces are not removed, though). Also, the contents of the message being delivered is made available to the command on standard input. Here the message is not overwritten, so line next is executed normally. So, your test code would be `/home/phil/bin/bash_internal_variables.sh > /home/phil/t` instead of xfilter "/home/phil/bin/bash_internal_variables.sh > /home/phil/t" Hope this helps. Milan ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140