on Fri, Aug 24, 2001 at 05:38:56PM -0700, Mike Egglestone ([EMAIL PROTECTED]) wrote: > Hi > > I have a txt file in this format: > > joe blow > john smith > john doe > > I would like to use "newusers" to add about 500 accounts to my system, > but how do I quickly make the txt file look like this: > > joe_blow:password:1001:1001:,,,/home/joe_blow:/bin/bash > john_smith:password:1002:1002:,,,/home/john_smith:bin/bash > > or > jblow:password:1001:1001:,,,/home/jblow:/bin/bash > > Is there some good vim commands that would allow me to add > the extra stuff that "newusers" needs in order to add the accounts? > Or is there some better way to add accounts from a txt file?
Interestingly enough, I've got to do a similar task.
The following awk script should get you started:
------------------------------------------------------------------------
#!/usr/bin/awk -f
{
first=$1
last=$2
user= substr( tolower( first ), 1, 1 ) tolower( last )
uid=1000+NR
gid=uid
printf( "%s:password:%d:%d:%s %s,,/home/$1$2:/bin/bash\n", \
user, uid, gid, first, last, uid \
)
}
------------------------------------------------------------------------
Save that as newusers.awk and make it executable. Invoke with:
$ ./newusers.awk < userlist
...where userlist is as you specify.
If you provide passwords as a third field, you can modify the script to
generate a password as well.
--
Karsten M. Self <[email protected]> http://kmself.home.netcom.com/
What part of "Gestalt" don't you understand? There is no K5 cabal
http://gestalt-system.sourceforge.net/ http://www.kuro5hin.org
Free Dmitry! Boycott Adobe! Repeal the DMCA! http://www.freesklyarov.org
Geek for Hire http://kmself.home.netcom.com/resume.html
pgpuERPjp2pk5.pgp
Description: PGP signature

