[Techtalk] help with python script for batch useradd
Carla Schroder
carla at bratgrrl.com
Tue Jan 6 12:21:22 EST 2004
Hiya,
Attached is a nice Python script that takes a comma-delimited text list, like
this:
carlas,Carla Schroder
nikitah,Nikita Horse
rubst,Rubs The Cat
Then it generates passwords, and adds all the users to the system. This was
written by Aaron Malone, who used to hang out here.
There's an improvement I've been trying to make:
How to make it enter the GECOS, or full-name field entries correctly? This is
the format of /etc/passwd:
username:passwd:UID:GID:full name,room number,work phone,home
phone,other:directory:shell
useradd does everything except username, passwd, and full-name. Each field is
colon-separated, and the 6 fields inside the GECOS (full-name) field are
comma-separated. Let's say your user list looks like this:
carlas,Carla Schroder,,,,foo
nikitah,Nikita Horse,,123-4567,equine
rubst,Rubs The Cat,101,,234-5678,,
How to tell Python to pass it in the correct format to useradd? useradd does
it like this:
# useradd -c "Rubs T Cat,101,,123-4567,feline" rubst
Thanks much!
--
~~~~~~~~~~~~~~~~~~~~~~~~~
Carla Schroder
www.tuxcomputing.com
this message brought to you
by Libranet 2.8 and Kmail
~~~~~~~~~~~~~~~~~~~~~~~~~
More information about the Techtalk
mailing list