[K12OSN] How about a scripting question :-)
Dan Young
dyoung at mesd.k12.or.us
Thu Nov 9 21:48:10 UTC 2006
Jim Kronebusch wrote:
> On Thu, 09 Nov 2006 13:21:06 -0800, Dan Young wrote
>> Jim Kronebusch wrote:
>>> Let's say I have a group called "Staff" in /etc/group with users x,y and z.
>>> How would I create a script that would grab the users from the group "Staff"
>>> and create a new file "/etc/mailusers" with all the users listed separately on
>>> their own line?
>> getent group Staff | cut -d':' -f4 | sed 's/,/\n/g' > /etc/mailusers
>
> Here is the current script with the cleaned up command to work with the group
> file directly.
>
> #!/bin/sh
> rm -f /root/mailusers
> getent group staff | cut -d':' -f4 | sed -e 's/,/@winonacotter.org OK,/g' -e
> 's/,/\n/g' > /etc/mailusers
> postmap hash:/etc/mailusers
>
> But I still have the problem with the last user not getting the
> "@winonacotter.org OK" appended. I am stumped with that right now.
The last user in the group doesn't have a comma after their name to be
substituted w/ "@winonacotter.org OK". How about:
#!/bin/sh
if [-f /etc/mailusers]; then rm -f /etc/mailusers; fi
touch /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
--
Dan Young <dyoung at mesd.k12.or.us>
Multnomah ESD - Technology Services
503-257-1562
More information about the K12OSN
mailing list