[K12OSN] How about a scripting question :-)

Dan Young dyoung at mesd.k12.or.us
Thu Nov 9 22:33:07 UTC 2006


Huck wrote:
> Jim Kronebusch wrote:
>> Anyhow when things weren't working I dumped the touch portion as well
>> since I
>> didn't know what it did. I figured if the rm command ran, touch
>> wouldn't be
>> able to find /etc/mailusers anyhow.  
>
> touch /etc/mailusers
>
> creates the file 'mailusers' in /etc

Shoot, I've sent you astray here. You need that /etc/mailusers rewritten
every time. Don't do the conditional [ -f ] , just delete /etc/mailusers
every time. Otherwise, you'll just keep appending all the group members
every time this runs; not good. The touch is redundant too, since the
">>" to append will create the file if it doesn't exist. Sorry for the
misdirection...

<hangs head in shame>

#!/bin/sh
rm -f /etc/mailusers
MAILUSERS=$(getent group staff | cut -d':' -f4 | sed 's/,/ /g')
for EACH in $MAILUSERS; do
  echo "$EACH at winonacotter.org OK" >> /etc/mailusers;
done
postmap hash:/etc/mailusers

-- 
Dan Young <dyoung at mesd.k12.or.us>
Multnomah ESD - Technology Services
503-257-1562




More information about the K12OSN mailing list