#! /usr/bin/perl 
#TJ MARCH 2004 for Newton system

system "tail -3 /etc/passwd > ~/mytail";
open PASSWO, '/root/mytail';

system "clear";
print ("************************************************\n");
print ("Newton's Interactive User Add");
print ("************************************************\n");

#####################WHICH NEWTON##########################
print ("************************************************\n");
print ("Which Newton will they live?[6?]: \n");
$newt = <STDIN>;
chomp($newt);
#################GET USER ID INFO##########################
$numb = 1;
while (<PASSWO>) {
    ($login, $passwd, $uid, $gid)= split /:/;
  
    $num[$numb]="User ID --->".$uid." Group ID --->".$gid;
    $numb++;
}

############
print ("The last three user ID's are:\n  $num[1], \n  $num[2], \n  $num[3]\n");
print ("\n");
print ("Enter user ID: \n");
$userid = <STDIN>;
chomp($userid);
print ("Enter group ID: \n");
$groupid = <STDIN>;
chomp($groupid);
#############################################################

#########################GET PERSONAL########################
print ("************************************************\n");
print ("What is the persons name?:  \n");
$Name = <STDIN>;
chomp($Name);
print ("What will be their user name?:  \n");
$user = <STDIN>;
chomp($user);
####################GET SHELL INFO############################

print ("************************************************\n");
print ("What shell does user want (tcsh or bash?): \n");
$shell = <STDIN>;
chomp($shell);
###############################################################

       $C = "useradd -c '".$Name."' -u ".$userid." -g ".$groupid." -s /bin/".$shell." -m -d /home/newton".$newt."/".$user." ".$user;
       print("Is $C OK?[y/n] \n");
$ans = <STDIN>; chomp($ans);

if ($ans eq "y"){system "$C"; $P="passwd ".$user; system "$P";}


print("\n");
print("Running /var/yp/make...\n");
system "cd /var/yp; make";
print("Done.\n");
