[rt-users] Batch user import?
Torsten Brumm
torsten.brumm at googlemail.com
Tue Aug 3 12:47:22 EDT 2010
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 at 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 at carthage.edu>
> Date: Thu, Jul 29, 2010 at 9:42 AM
> Subject: Batch user import?
> To: rt-users <rt-users at 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 at carthage.edu
>
>
>
> --
> Carol Sabbar
> Director of Information Services
> Carthage College
> csabbar at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20100803/286f2cb5/attachment.htm>
More information about the rt-users
mailing list