[rt-users] CLI Question - Add Users to group per Scrip

Torsten Brumm torsten.brumm at googlemail.com
Tue Feb 27 07:15:19 EST 2007


Hi Joe,

your scrip looks fine so far, but i get a strange error message:

[Tue Feb 27 12:29:07 2007] [crit]: Can't call method "AddMember" on an
undefined value at AddUsersToGroups.pl line 38. (/opt/rt36/lib/RT.pm:346)
Can't call method "AddMember" on an undefined value at
AddUsersToGroups.plline 38.

And line 38 looks like:

my($status, $msg) = $group->{$groupname}->AddMember($user->id);
I'm not sure if the AddMember is defined in this routine, but i found:
SetMemberId VALUE<http://rt36-messenger.int.kn/Developer/Perldoc/Body.html?n=RT::GroupMember#___top>

Have you tried it?

Torsten
2007/2/15, Joe Casadonte <joe.casadonte at oracle.com>:
>
> On 2/15/2007 11:04 AM, Torsten Brumm | Kuehne + Nagel wrote:
>
> > Again just another question for the CLI Part. Has anyone a idea how to
> add a
> > set of users per scrip to a group?
> >
> > Lets say, i have a list of 500 User that are needed to be member of a
> single
> > group?
>
> I did something similar via a full perl script (as opposed to using the
> CLI).  Here are some excerpts (untested in this form):
>
> #!/usr/bin/perl -w
>
> use strict;
> use lib "/opt/rt3/lib";
>
> use RT;
> use RT::Interface::CLI qw(CleanEnv GetCurrentUser);
> use RT::Group;
> use RT::User;
>
> CleanEnv();
> RT::LoadConfig();
> RT::Init();
>
> my($groupname) = 'FooBar';
> my($group) = RT::Group->new($RT::SystemUser);
> $group->LoadUserDefinedGroup($groupname);
> die qq([ERROR] Cannot load group "$groupname"\n) unless $group->id;
>
> my(@users) = GetListOfUsernames();
> foreach my $username (@users) {
>     my($user) = RT::User->new($RT::SystemUser);
>     $user->Load($username);
>     die qq([ERROR] Could not load user "$username" -- see log for
> details\n) unless $user->id;
>
>     my($status, $msg) = $Groups->{$groupname}->AddMember($user->id);
>     die qq([ERROR] Cannot add user "$id" to group "$groupname" - $msg\n)
> unless $status;
> }
>
> --
> Regards,
>
>
> joe
> Joe Casadonte
> joe.casadonte at oracle.com
>
> ==========                                                  ==========
> == The statements and opinions expressed here are my own and do not ==
> == necessarily represent those of Oracle Corporation.               ==
> ==========                                                  ==========
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>
> Community help: http://wiki.bestpractical.com
> Commercial support: sales at bestpractical.com
>
>
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com
>



-- 
MFG

Torsten Brumm

http://www.torsten-brumm.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20070227/ab047615/attachment.htm>


More information about the rt-users mailing list