On Monday 29 January 2007 10:59, John Arends wrote: > I have the book right next to me. (It is a very good book, and buying it > was the least I could do to support this project.) > > The problem is the book just touches on the subject. As someone who is > trying to learn perl I can't pick up enough to figure out what to do > from the chapter on the perl API.
Trying to learn Perl and trying to learn the RT API at the same time is *very* ambitious. The Wiki is your friend. The various modules in RT do have manual pages, too. For example, to find out what methods are available for a RT::Ticket object, just issue this command: $ perldoc /path/to/rt/lib/RT/Ticket_Overlay.pm Another fine source of information is the code itself. Especially the embedded test code in each module. Of course this is quite a challenge, if you do not know Perl. :-( > Maybe if someone gives a couple examples, I can work with that. > > A few things I would like to do (in no particular order): # initialization for a RT batch program # # NOTE: NO ERROR CHECKING below -- very bad -- see the code to # find out how to check return values from various methods use warnings; use strict; use lib '/path/to/rt/lib'; use RT::Interface::CLI; RT::LoadConfig(); RT::Init(); open my $fh, '> /path/to/log/file' or die "can't open /path/to/log/file: $!\n"; > -see a list of all the members of a group my $group = RT::Group->new($RT::SystemUser); $group->LoadUserDefinedGroup('my group name'); my $users = $group->UserMembersObj(); while (my $user = $users->Next()) { print $fh $user->Name(), "\n"; } > -add/remove a user from a group my $group = RT::Group->new($RT::SystemUser); $group->LoadUserDefinedGroup('my group name'); my $user = RT::User->new($RT::SystemUser); $user->Load('my_user_id'); $group->AddMember($user->PrincipalId()); # remove from group left as an exercise > -create a user my $user = RT::User->new($RT::SystemUser); $user->Create(Name => 'my_user_id', Password => 'secret', RealName => 'John Doe', EmailAddress => [EMAIL PROTECTED]', Privileged => 0); > -set a user as privileged > -create a ticket (and populate a custom field while doing it) These are left as an exercise for the reader. Use the code, Luke. :-) -- Garry T. Williams --- 678-370-2438 _______________________________________________ http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users Community help: http://wiki.bestpractical.com Commercial support: [EMAIL PROTECTED] Discover RT's hidden secrets with RT Essentials from O'Reilly Media. Buy a copy at http://rtbook.bestpractical.com