|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
Re: relay_recipients_maps / generic clash
From: Sandy Drobic (postfix-users
japantest.homelinux.com)
Date: Thu Oct 05 2006 - 16:30:31 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
John Knappers wrote:
>> John Knappers wrote:
>>
>>
>>>>
>>>> # Just add these lines to your script
>>>> #
>>>> domains=("
example1.com" "
example2.com" "
example3.com")
>>>> #
>>>> cat in_complete_relay_recipient_maps | while read line;
>>
>> grep "example.com" cat in_complete_relay_recipient_maps | while read
>> line;
>>
>>>> do
>>>> {
>>>> user_name=`echo $line|cut -f1 -d"
"`
>>>> for i in `echo ${domains[*]}`; do
>>>> echo -e "$user_name$i" >> /etc/postfix/relay_recipients
>>>> done
>>>> }
>>>> done
>>
>> Do another grep run for the other domain and adapt the domains list.
>> There are many ways to do this, but this is probably the easiest for
>> you to understand.
>>
>>>>
>>> Tonight I'm gonna try this.
> I'm trying to create a nice script out of you suggetions, ans it start
> to work ! :)
> I changed: grep "example.com" cat in_complete_relay_recipient_maps |
> while read line;
> in cat relay_recipients_imcomplete_smal |grep "domain1.com" | while read
> line;
It gives the same result though my direct grep needs one command (cat)
less, so it's a bit less overhead.
> and
> # echo -e "$user_name$i" >>
> /home/john/testing/relay_recipients_smal in
> printf "$user_name$i\tOK\n" >>
> /home/john/testing/relay_recipients_smal
> (was missing the tab and OK)
Correct. It doesn't really matter, what the result is, though. You could
also return the key again, which is sometimes nice for debugging work.
Postfix doesn't care as long as the lookup is successful it doesn't use
the result in any way (for relay_recipient_maps).
> But there is one thing left I can't get fixed.
> domains=("
example1.com" "
example2.com" "
example3.com")
> It would be nice it read this list out of the generic file(s). But I
> failed to do so.
> At the comand line I was able to at get the following output:
> "
example1.com" "
example2.com" "
example3.com"
> with the syntax:
> awk '!length < 1 && !/#/ && /
/h {printf ("\"%s\" ",$1)}' generic_smal
> But is still misses the ( ) surrounding the domain list and adding the
> line:
> domains=awk '!length < 1 && !/#/ && /
/h {printf ("\"%s\" ",$1)}'
> generic_smal
> causes the script to fail
> Sandy, do you know how to do this right?
> Thanx for you efford.
# set domainsnew as result of awk command (one line!)
domainsnew=`awk '!length < 1 && !/#/ && /
/h {printf ("\"%s\" ",$1)}'
generic`
arraydom=($domainsnew)
echo $domainsnew
# number of elements in array
echo ${#arraydom[*]}
Sandy
--
List replies only please!
Please address PMs to: news-reply2 (
) japantest (.) homelinux (.) com
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]