[K12OSN] How about a scripting question :-)

Mike Oliveri moliveri at rb60.com
Thu Nov 9 20:23:26 UTC 2006


This might be too easy, but give this a shot. Copy /etc/group to a new
file and delete all the other lines until you have your comma-delimited
group of users.

Then use sed to turn all of the commas into newlines (/n). 

sed s/\,/\/n/g newfile >> /etc/mailusers

I've escaped the comma just in case. The forward slash for the newline
does have to be escaped, though.

That's off the top of my head. I'm fuzzy on such things. Might want to
experiment with a different output file first! :)

Take care,
Mike
 

-----Original Message-----
From: k12osn-bounces at redhat.com [mailto:k12osn-bounces at redhat.com] On
Behalf Of Jim Kronebusch
Sent: Thursday, November 09, 2006 2:19 PM
To: k12osn at redhat.com
Subject: [K12OSN] How about a scripting question :-)

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?

Example:
Script reads /etc/group for the line matching Staff (I can pull that
with "grep Staff /etc/group) and the result is -
Staff:x:501:jim,tommy,john Then builds the new file named /etc/mailusers
which is formatted like so - jim tommy john

Make sense?  I would think this to be possible.  My thought is this
would answer my postfix question earlier.  I could set
"local_recipient_maps=hash:/etc/mailusers" and then have this script run
after any changes in Webmin to the users module.  The script would also
have a line at the end that ran "postmap /etc/mailusers" to update the
database.

Sound feasible

Thanks,

Jim Kronebusch
Cotter Tech Department
507-453-5188


--
This message has been scanned for viruses and dangerous content by the
Cotter Technology Department, and is believed to be clean.

_______________________________________________
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