One more time, I am asking you to post a short but COMPLETE program.
Until that happens, I'm done with this thread, and wish you well.
Paul Lalli
OKAY, here's the code, everthing works except when i want to do begin
and end substitution. I've only coding perl for a MONTH.
#!/bin/perl
use strict;
use Sys::Hostname;
use File::Copy;
chomp(my $date = `date '+%m%d%y'`);
#I know this looks a little messed up but works.
my $name_change = "./UIDs_n_IDs_Not_Match";
open(name_change,"$name_change") or die ("Can't open
$name_change:$!\n");
my @name_change2 = <name_change>;
# Checking Host
if ($host eq "powerhouse"){
# Setup output files
my $passwd_out = "passwd.out";
open (passwdout,">$passwd_out") or die ("Can't create $passwd_out
file: $!\n");
my $shadow_out = "shadow.out";
open (shadowout,">$shadow_out") or die ("Can't create $shadow_out
file: $!\n");
my $group_out = "group.out";
open (groupout,">$group_out") or die ("Can't create $group_out file:
$!\n");
my $passwd_file = "/etc/passwd";
my $shadow_file = "/etc/shadow";
my $group_file = "/etc/group";
copy("$passwd_file","$passwd_file.$date");
copy("$shadow_file","$shadow_file.$date");
copy("$group_file","$group_file.$date");
@ARGV=("$passwd_file","$shadow_file","$group_file");
while (my $line=<>) {
#@pass_info = getpwnam((split(/:/,$_))[0]);
# Traverse the UIDs_n_IDs_Not_Match file and R&R unix ids w/ NT
ids.
foreach (@name_change2) {
my
($NULL1,$unixid,$NULL2,$unixuid,$NULL3,$NULL4,$ntid,$NULL5,$ntuid) =
split /\s*\|\s*/;
#THIS WORKS BUT I DON'T WANT TO USE "^$unixid:" I WANT TO USE
"^$unixid$"
$line =~ s/^$unixid:/$ntid:/g;
} #end of foreach
if ($ARGV eq "$passwd_file") { print passwdout $line; }
elsif ($ARGV eq "$shadow_file") { print shadowout $line; }
elsif ($ARGV eq "$group_file") { print groupout $line; }
}
# Close input files
close (name_change);
# Close output files
close (passwdout) or die ("Can't close passwd.out file; $!\n");
close (shadowout) or die ("Can't close shadow.out file; $!\n");
close (groupout) or die ("Can't close group.out file; $!\n");
move("$passwd_out","/tmp/passwd.mv") or warn "Move Failed: $!";
chmod(0444, "/tmp/passwd.mv") or warn "chmod Failed: $!";
} #end if
Here's an example of the UIDs_n_IDs_Not_Match file
UnixUserID | dopey | UID | 10 | does not match LOGIN and UID found in
LDAP | ldapusername | jdoe | LDAPUID | 106520 | UNIXNAME | John Doe |
LDAPname | John Doe | UnixEmployid | 00000 | LDAPemployid | 00000 |
email | (e-mail address removed)