Have look onto this tiny piece of code…
createuser.pl
#!/usr/bin/perl
use strict;
use warnings;
BEGIN { die “You must define $RT_HOME\n”
unless exists $ENV{RT_HOME} };
use lib “$ENV{RT_HOME}/lib”;
use RT;
RT::LoadConfig();
RT::Init();
use RT::Interface::CLI qw(GetCurrentUser loc);
use RT::Tickets;
my $CurrentUser = GetCurrentUser();
die loc(“No RT user found.\n”) unless ($CurrentUser->Id);
die “We need exactly 2 Arguments, Name & Email\n” unless ($#ARGV==1);
my $UserName=shift @ARGV;
my $Email=shift @ARGV;
my $User = RT::User->new($CurrentUser);
my
($id,$Message)=$User->Create(Name=>$UserName,EmailAddress=>$Email,Privileged=>1,Password=>‘apassword’);
if ($id){
print $Message.“\n”;
}
else{
print"This is a error!\n$Message\n";
}
triggered from a shell script like these:
#!/bin/bash
export RT_HOME=/opt/rt3
P1=/opt/rt3/local/bin/
U1=/opt/rt3/local/bin/userlist
while read zeile; do
set – $zeile
echo "Bearbeite User: "$1 $2
/usr/bin/perl ${P1}creatertuser.pl $1 $2
done<$U1
you need a csv file called userlist with the needed values.2010/8/3 Carol Sabbar csabbar@carthage.edu
Checking to see if my messages are going through. I have asked this
question twice and haven’t seen my question go out or any answers to it.
Please! Need help!
---------- Forwarded message ----------
From: Carol Sabbar csabbar@carthage.edu
Date: Thu, Jul 29, 2010 at 9:42 AM
Subject: Batch user import?
To: rt-users rt-users@lists.bestpractical.com
I’d like to import users into Request Tracker from a CSV or similar file.
I found some info on gossamer, but not enough to get a working solution.
Any really practical solutions are really appreciated.
–
Carol Sabbar
Director of Information Services
Carthage College
csabbar@carthage.edu
–
Carol Sabbar
Director of Information Services
Carthage College
csabbar@carthage.edu
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.brumm.me
http://www.elektrofeld.de