[Techtalk] help with python script for batch useradd

Carla Schroder carla at bratgrrl.com
Tue Jan 6 13:34:30 EST 2004


On Tuesday 06 January 2004 11:51 am, Aaron Malone wrote:
> On Tuesday 06 January 2004 13:21, Carla Schroder wrote:
> > This was written by Aaron Malone, who used to hang out here.
> 
> And decided to rejoin the list and see what was going on these days. :)
> 
Welcome back!

> Actually, the script I gave you should work fine for that unaltered.  
> It actually uses ':' as the separator character between username and 
> realname, so if you have, say:
> carlas:Carla Schroder,,,,foo
> as input, it should add you as:
> useradd -m -c "Carla Schroder,,,,foo" carlas

Well, here's what happens when I try:

# python mass_add.py < newusers-deb  > passwords.out
Traceback (most recent call last):
  File "mass_add.py", line 24, in ?
    username, realname = line.split(':')
ValueError: unpack list of wrong size

> 
> The bug you may hit there is if someone has a colon in their GECOS/
> realname field.  This can be fixed by changing line 24 to:
>     username, realname = line.split(':', 1)

I used this list:

dawns,Dawn Marie Schroder,,,,foo
nikitah,Nikita Horse,,123-4567,equine
rubst,Rubs The Cat,101,,234-5678,,

thanks!

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~
Carla Schroder
www.tuxcomputing.com
this message brought to you
by Libranet 2.8 and Kmail
~~~~~~~~~~~~~~~~~~~~~~~~~



More information about the Techtalk mailing list