Script to create users in linux



This script create accounts in linux.
the password is the same as the user.


#! /usr/bin/perl -w 
use strict;


my $i=””; 
my $FInput; 
my @arrContas=(); 
my $strEncPwd=""; 
my $strSalt="LX";


if(@ARGV != 1)
{
      print("Sintaxe: ./CreateAccounts.pl \n"); exit 1;
}

if(!open($FInput,"$ARGV[0]"))
{
     print("Error reading the input file\n"); exit 1;
}

@arrContas=<
$FInput>;
close($FInput);

for $i (@arrContas)
 {
      chomp($i); 
      $strEncPwd=crypt($i,$strSalt); 
      `useradd -p '$strEncPwd' -m $i`; 
      print("Account $i sucessful created\n");
}

0 comentários:

Enviar um comentário