[rt-users] Add group membership via CLI

Asif Iqbal vadud3 at gmail.com
Tue May 14 21:29:39 EDT 2013


oops.. sorry for posting twice. I thought it did not make it to the ML
first time


On Tue, May 14, 2013 at 9:28 PM, Asif Iqbal <vadud3 at gmail.com> wrote:

> I am trying to add a list of UIDs into one of my group and it is failing.
>
> I am running the script that was posted with this subject on Nov 22, 2010
> by tanhuy.langloy at bt. I am running it on RT 3.8.2
>
> #!/usr/bin/perl
> # Utilisation : ./rtgroupmember.pl GROUPNAME
> # Attention : Le fichier list.txt doit être correctement rempli
>
> use strict;
> use lib "/opt/rt3/lib";
>
> use RT;
> use RT::User;
> use RT::Interface::CLI;
>
> RT::LoadConfig();
> RT::Init();
>
> my $user = new RT::User($RT::SystemUser);
> my $group = new RT::Group($RT::SystemUser);
> my $inputgroup = $ARGV[0];
>
> $group->LoadUserDefinedGroup( $inputgroup );
>
> open FILE, "usernames.txt" or die $!;
>
> while (<FILE>)
> {
>   $user->Load( $_ );
>   $group->AddMember( $user->PrincipalObj->Id );
>   #print $user->PrincipalObj->Id ."\n";
> }
>
> close FILE;
>
>
> $ ./rtgroupmember.pl MYGROUP
>
> [Wed May 15 01:23:15 2013] [error]: Couldn't get principal for not loaded
> object (/opt/rt3/lib/RT/User_Overlay.pm:1154)
> [Wed May 15 01:23:15 2013] [crit]: Can't call method "Id" on an undefined
> value at ./rtgroupmember.pl line 26, <FILE> line 1.
> (/opt/rt3/lib/RT.pm:377)
> Can't call method "Id" on an undefined value at ./rtgroupmember.pl line
> 26, <FILE> line 1
>
> Any suggestion would be appreciated
>
> Thanks
>
> --
> Asif Iqbal
> PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
>
>


-- 
Asif Iqbal
PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20130514/ffca506b/attachment.htm>


More information about the rt-users mailing list