[K12OSN] How about a scripting question :-)

Mike Oliveri moliveri at rb60.com
Fri Nov 10 14:21:04 UTC 2006


Why not just use > instead of >>? > should replace the file rather than
append, and then you wouldn't need to remove the file, either.

Mike 

-----Original Message-----
From: k12osn-bounces at redhat.com [mailto:k12osn-bounces at redhat.com] On
Behalf Of Dan Young
Sent: Thursday, November 09, 2006 4:33 PM
To: Support list for open source software in schools.
Subject: Re: [K12OSN] How about a scripting question :-)

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

_______________________________________________
K12OSN mailing list
K12OSN at redhat.com
https://www.redhat.com/mailman/listinfo/k12osn
For more info see <http://www.k12os.org>




More information about the K12OSN mailing list