Hello, everybody
I have a csv file with firstname, lastname, group
and need to create user and group if it doesn't exist.
But the problem is that i must not use useradd ou groupadd.
I must read user from csv, and then check if user exist, and if group
exist.
i've started like this, but i don't know how to check if user exist,
and group exist.
Here is the starting of my code.
$file = './liste_etudiants.csv';
open (FICH,$file) ||die ("Fichier innexistant");
while ($line = <FICH>)
{
#on splie chauqe ligne
($field1,$field2,$field3) = split (',', $line);
#on enlève le charcatère "
($field1) =~ s/"//g;
($field1) = substr($field1, 0, 1);
($field2) =~ s/"//g;
($field3) =~ s/"//g;
($login) = $field1 . $field2;
print "$field1 : $field2 : $field3 -- le login sera login$login sera
membre de $field3 \n";
}
#ecrire dans un fichier
#open(F_WRITE,">./touche.txt") || die "E/S : $!\n";
#print $filed1;
close(FICH);
I wanted to test with tis kind of test
open (FILE,"/etc/passwd");
while () {
chomp;
/^([a-z][a-z0-9]*):x:([0-9]+):([0-9]+):/;
#si le user id=user id dans le fichier on incrémante de 1 le uid
if ($2 == $uid) { $uid++; }
}
but don't know how.
I f someone could help me.
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/