Source

samba_backup / users_manage.py

#!/usr/bin/python
import csv
import os
import sys

FILENAME = sys.argv[1]

try:
    data = csv.reader(open(FILENAME), delimiter='\t')
except:
    print 'Error en el archivo de usuarios'
    sys.exit()

for line in data:
    user = line[0].lower()
    passw = 'y13S.%s' % line[0].split('.')[0]
    print "User: %s" % (user)
    bash = 'useradd -g usuarios %s' % (user)
    #print bash
    os.system(bash)
    bash = '(echo %s; echo %s) | smbpasswd -s -a %s' % (passw, passw, user)
    #print bash
    os.system(bash)

print "Terminado"