Problem with the rt perl module and authentication

I’m trying to run a script which uses the RT::Interface::CLI and I get
the following error from the command line. Anyone get this error?
Below is the code using the perl interface and below that is and example
call from the command line. I believe that the problem is probably with
GetCurrentUser() but I am not sure.

Thanks

The error is …

Couldn’t load from the users database.
(/opt/rt3/lib/RT/CurrentUser.pm:145)

Here is a test script …

#!/usr/bin/perl -w

use lib ("/opt/rt3/local/lib","/opt/rt3/lib");
use RT::Interface::CLI;
use RT;
use RT::Ticket;
use RT::CurrentUser;
use Getopt::Long;

$queue = ‘’;
$body = ‘’;

GetOptions (“queue=s” => $queue,
“subject=s” => $subject,
“owner=s” => $owner,
“requestor=s” => $requestor,
“priority=s” => $priority,
“body=s” => $body,
“AdminCc=s” => $AdminCc,
“cc=s” => $cc,
“RefersTo=s” => $RefersTo,
“ReferredToBy=s” => $ReferredToBy,
“DependsOn=s” => $DependsOn,
“Parents=s” => $Parents
);

setting some defaults

if ($queue eq ‘’)
{
print_usage();
exit (0);
}

if ($body eq ‘’)
{
$body=’ ';
}
RT::LoadConfig();
RT::Init();

if ($owner eq ‘’) {$owner = ‘Nobody’;}

my $CurrentUser = RT::Interface::CLI::GetCurrentUser();

use MIME::Entity;

my $ticket = new RT::Ticket($CurrentUser);
my $ticket_body = MIME::Entity->build(Data => $body,
Type => ‘text/plain’);
my %ticket_vals = ( Queue => $queue,
Subject => $subject,
Owner => $owner,
Requestor => $requestor,
InitialPriority => $priority,
MIMEObj => $ticket_body,
AdminCc => $AdminCc,
Cc => $cc,
‘RefersTo’ => $RefersTo,
‘ReferredToBy’ => $ReferredToBy,
‘DependsOn’ => $DependsOn,
‘MemberOf’ => $Parents
);

my ($id, $transaction_object, $err) = $ticket->Create(%ticket_vals);
print $err . “\n” if $err;

This is a test call of the script.

./test.pl -queue=“Development” -subject=“This is a test subject for test
script” -owner=‘bob’ -requestor=‘bob@bob.com’ -priority=99 -body=“This
is the body of the ticket”

At Tuesday 12/20/2005 04:20 PM, Rappaport, Evan wrote:

Content-class: urn:content-classes:message
Content-Type: multipart/alternative;
boundary=“----_=_NextPart_001_01C605AB.38B09B66”

I’m trying to run a script which uses the RT::Interface::CLI and I get the
following error from the command line. Anyone get this error? Below is
the code using the perl interface and below that is and example call from
the command line. I believe that the problem is probably with
GetCurrentUser() but I am not sure.

Thanks

The error is ….

Couldn’t load from the users database.
(/opt/rt3/lib/RT/CurrentUser.pm:145)

Check the RT User info for the user you want to be the current user. That
user must have ‘gecos’ set to the O/S username you use when running the
Perl script.

By the way, do you use the Perl debugger? That would allow you to step
throug hthe program and determine exactly where the error is occurring.

Good luck,
Steve

That was the problem, all fixed now. Thanks.From: Stephen Turner [mailto:sturner@MIT.EDU]
Sent: Wednesday, December 21, 2005 10:11 AM
To: Rappaport, Evan; rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Problem with the rt perl module and
authentication

At Tuesday 12/20/2005 04:20 PM, Rappaport, Evan wrote:

Content-class: urn:content-classes:message
Content-Type: multipart/alternative;
boundary=“----_=_NextPart_001_01C605AB.38B09B66”

I’m trying to run a script which uses the RT::Interface::CLI and I get
the
following error from the command line. Anyone get this error? Below
is
the code using the perl interface and below that is and example call
from the command line. I believe that the problem is probably with
GetCurrentUser() but I am not sure.

Thanks

The error is …

Couldn’t load from the users database.
(/opt/rt3/lib/RT/CurrentUser.pm:145)

Check the RT User info for the user you want to be the current user.
That user must have ‘gecos’ set to the O/S username you use when running
the Perl script.

By the way, do you use the Perl debugger? That would allow you to step
throug hthe program and determine exactly where the error is occurring.

Good luck,
Steve