on Sat, Dec 08, 2001 at 12:57:19AM +0000, Gerard Robin (robin.jag@free.fr) wrote:
> Hello,
> does any script exist, which creates 30 users automaticaly,
> with the list of 30 persons containing their name, christian name, etc...
> instead of using 30 times "adduser" ?
There's the "newusers" command, which can be passed an input file. The
format's a bit complex, so I've written a helper script to generate
appropriate input.
It's called newusers.awk, which takes as input a file in the form:
first-name last-name password
The invocation argument is:
./newusers.awk <starting userID> <input file>
Attached.
--
Karsten M. Self <kmself@ix.netcom.com> http://kmself.home.netcom.com/
What part of "Gestalt" don't you understand? Home of the brave
http://gestalt-system.sourceforge.net/ Land of the free
Free Dmitry! Boycott Adobe! Repeal the DMCA! http://www.freesklyarov.org
Geek for Hire http://kmself.home.netcom.com/resume.html
#!/usr/bin/awk -f
# Script to create a file suitable for use in the 'newusers' command,
# from a file consisting of user IDs and passwords in the form:
# First Last password
# Copyright (c) KMSelf Sat Aug 25 20:47:38 PDT 2001
# Distributed under GNU GPL v 2, or at your option, any later version.
# This program is distributed WITHOUT ANY WARRANTY.
BEGIN {
# Assign starting UID, GID
if ( ARGC > 2 ) {
startuid = ARGV[1]
delete ARGV[1]
}
else {
printf( "Usage: newusers <startUID> <file>\n" \
"...where startUID is the starting userid to add, and file is \n" \
"an input file in form <first name> <last name> <password>\n" \
)
exit
}
infile = ARGV[1]
printf( "Starting UID: %s\n\n", startuid )
}
/^#/ { next }
{
++record
first = $1
last = $2
passwd = $3
user= substr( tolower( first ), 1, 1 ) tolower( last )
uid = startuid + record - 1
gid = uid
printf( "%s:%s:%d:%d:%s %s,,/home/%s:/bin/bash\n", \
user, passwd, uid, gid, first, last, user \
)
}
Attachment:
pgpThSLDkAk2_.pgp
Description: PGP signature