Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another scripting problem

Status
Not open for further replies.

hermxl1

IS-IT--Management
Feb 12, 2004
24
US
Hi all;

I want to use nsradmin to "add" an additional group to a long list of servers. I don't want to use the update function, becuause it will remove all of the groups a client is already a member of. And I don't want to use the edit function because then I would have to edit all 300 clients by hand.

Anyone have any ideas on how I can add a group to each client without screwing up their existing config????

Thanks,

Herman
 
You can do it with the following logic:

- For each client get the list of groups they belong to through nsradmin (Client_A belongs to Group_A, Group_B)
- Edit the client to include ALL the groups you want the client to be in (Client_A belongs to Group_A, Group_B, Group_C)

In simpler terms, you edit the entire "group" resource of the client to add ALL the groups you would want the client to be in, including the existing ones.
 
Yeah,
I figured I'd have to do it that way. I was hoping there was something with the update command to help me out because I'm not a good enough scripter to handle the group field if it comes out on multiple lines. Example:

group: First_Group, Second_Group
group: First_Group, Second_Group
Third_Group, Fourth_Group
group: First_Group, Second_Group

When the group contains multiple lines of output, how can I make sure my script variable catches all of the groups? That's my problem.

I realize this is really more of a scripting skills issue than a Networker one, but in 15 years of UNIX experience scripting is the one thing I've tried to avoid. :) Nowadays it haunts me.

Herm
 
Though nsradmin splits the output, it actually can be taken as a single string. For each line, use the cut command to take the group names alone

cut -d: -f2

gives you the list of groups comma separated which you can again separate with cut to obtain individual group names.

HTH, Ram.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top