[rt-users] Add group membership via CLI

Emmanuel Lacour elacour at easter-eggs.com
Fri Nov 19 14:08:18 EST 2010


On Fri, Nov 19, 2010 at 06:16:08PM +0000, tanguy.lagroy at bt.com wrote:
> Thanks for your help Emmanuel. 
> What's the better ? Perl script or mysql script ?
> 

Perl script using the RT API, sample untested code, without error
checking (get it with ($val, $msg) = method; die $msg unless ( $val ); ):

#!/usr/bin/perl -w

use strict;
use lib "/home/rt/rt/lib";
use RT;
use RT::Interface::CLI qw( CleanEnv );

CleanEnv();
RT::LoadConfig();
RT::Init();

my $User = RT::User->new ( $RT::SystemUser );
$User->Create( Name => NAME, EmailAddress => EMAIL, ... );

my $Group = RT::Group->new ( $RT::SystemUser );
$Group->LoadUserDefinedGroup( GROUPNAME );

$Group->AddMember( $User->PrincipalObj->Id );




More information about the rt-users mailing list