NIS -> local rt users script

Hola -

I grew a quick script out of Dave Maze’s script to add local users to
RT to import users from NIS with their current crypted password, and
thought that others might find it useful:

#!/usr/local/bin/perl -w

rtadduser: add a local user to RT

David Maze dmaze@cag.lcs.mit.edu

$Id$

2003-11-27 Modified by gwen@reptiles.org for the local environment

changed to read from ypcat

Don’t forget to modify the email address field appropriately.

use strict;
use English;

specify where to find the RT libs, which are in a non-standard path,

and thus not in @INC

use lib qw(/usr/local/rt3/lib);

use RT::Interface::CLI qw(CleanEnv);
use RT::User;

pipe the results of the command ‘ypcat passwd’ into a filehandle

this is lazy, and presumes that ypcat is in your path

open USERS, “ypcat passwd|”;

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

while ()
{
my ($name, $passwd, $uid, $gid, $gcos, $dir, $shell) = split /:confused: ;

    my $UserObj = new RT::User($RT::SystemUser);
    $UserObj->Create(Name => $name,
            EmailAddress => "$name\@example.com",
            RealName => $gcos,
            CryptedPassword => $passwd,
            Privileged => 1);

}

“A cat spends her life conflicted between a deep, passionate and profound
desire for fish and an equally deep, passionate and profound desire to
avoid getting wet. This is the defining metaphor of my life right now.”