Hey · IT Guy!

HOME Archive Tags GITHUB ABOUT RSS

A script to format /etc/security for AIX

2013-03

I wrote a script to format /etc/security on AIX like Linux:/etc/passwd as the requirement from Customer.


\#!/usr/bin/perl -w
use strict;
use File::Basename qw(fileparse);
my @lsdir= glob "/home/hp09396/Spasswd/Spasswd*";
foreach my $dir (@lsdir) {
    my ($fname,$fdir)=fileparse($dir);
    open (FH,"<","$dir") or die "coudn't open password file:$!\n";
    open (OU,">","/tmp/$fname") or die "coudn't creat the file:$!\n";
    while (){
        chomp if  $_=~/=/ or $_=~/\w+:/;
        s/\s+password\s+=\s+//g;
        s/\s+lastupdate\s+=\s+/:/g;
        s/\s+flags\s+=\s+/:/g;
        print OU
  }
print OU "\n";
\#rename("/tmp/passwd_","$name");
close(FH);
close(OU);
};
chmod 0644, glob "/tmp/Spasswd*";
</pre></code>