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


2003-11-27 Modified by 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|”;


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

    my $UserObj = new RT::User($RT::SystemUser);
    $UserObj->Create(Name => $name,
            EmailAddress => "$name\",
            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.”