[kwlug-disc] using tee to pipe to multiple programs from /etc/valiases

Robert P. J. Day rpjday at crashcourse.ca
Wed Apr 14 15:50:01 EDT 2010


On Wed, 14 Apr 2010, Khalid Baheyeldin wrote:

> On Wed, Apr 14, 2010 at 2:55 PM, Robert P. J. Day <rpjday at crashcourse.ca> wrote:
>
>        so here's the deal -- i have a system where a /etc/valiases file is
>       set up to pipe incoming input destined for all email addresses in a
>       given domain to a single PHP script:
>
>        /etc/valiases/<domain name>
>        *:  "| myphpscript.php"
>
>       works great, no problem.  *now* i want to have precisely the same
>       incoming emails sent to *multiple* programs/scripts and, based on my
>       testing with the "tee" command, i can do it thusly:
>
>        $ <input generator> | tee >(pgm1) >(pgm2) ... >(pgmn) > /dev/null
>
>       (that last redirection is to stop anything from going further on
>       stdout.)
>
>        i've tested that incantation on the command line and it works fine.
>       but when i try the same thing in the /etc/valiases/<domainname>
>       file,
>       it fails utterly.  so i'm fairly confident i know how to use tee to
>       do
>       this, i just don't know enough about valiases to know what kind of
>       restrictions i have to work with.  is what's in there executed in a
>       restricted shell so that that tee variation won't work?  thanks.
>
>
> I don't know much about valiases either ...
>
> But two possibilities:
>
> - valiases need the full path name to the executables.

  they're there.

> - valiases does not execute stuff with a normal sh/bash shell so the
> redirection syntax does not work?

  that is the only possibility that seems to make sense so i snuck
around the problem by using a valiases entry of

    *: "| .../dup_out.sh"

where my dup_out.sh script does all the actual work:

    tee >(pgm1) >(pgm2) ... > /dev/null

where, obviously, all of pgm<n> are executables that read from stdin.
problem solved.  and i can't imagine that the additional overhead from
executing that script is going to be noticeable.

rday
--

========================================================================
Robert P. J. Day                               Waterloo, Ontario, CANADA

            Linux Consulting, Training and Kernel Pedantry.

Web page:                                          http://crashcourse.ca
Twitter:                                       http://twitter.com/rpjday
========================================================================


More information about the kwlug-disc mailing list