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!

help script variable

Status
Not open for further replies.

alexia32

Technical User
Jul 31, 2007
156
NZ
Hi,

I have an variable that contains usernames
TMAIX = usernam1, unernam2, unsernam3 etc...

What I want to do if I have to add a new user on sudoers on the TMAIX I would like to check first if this new user already there (so for that I am using cat file|grep -q usernam and check $?) but I need help to add the new user at the end of the line...

Thanks in advance

Cheers
Al.
 
Try this:

TMAIX=$TMAIX$usernam

in case you want to put comma then it would be like this

TMAIX=$TMAIX,$usernam

Regards,
Khalid
 
Just for interest, I found that keeping user lists in our sudoers files became a management headache so I ended up changing the permissions to groups
i.e. Before
Code:
User_Alias SUPPORT1 user1, user2, user3
SUPPORT1 host = command
After
Code:
%support1 host = command
and
Code:
lsgroup -a users support1
#support1 users=user1,user2,user3,
This means I can
[ol]
[li]Give users access permissions quickly and easily with chgrpmem[/li]
[li]Write reports for the security team on exactly whom has permissions to do what[/li]
[li]When a user leaves I don't have to delete them from a number of files[/li]
[/ol]

Ceci n'est pas une signature
Columb Healy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top