[ back to toc ]

Auto Generate User accounts

Date: 2002/05/12 19:21


I am trying to autogenerate user accounts and passwords. I have a .csv
file which has the users first and last name. I want to extract that info
and automatically generate a user account and password for them. Is that
possible. I have a script now that generates a password but want to know
if I can grab the csv file and generate accounts and password with them.

#!/bin/bash x=100;
while [ "$x" -le 700 ]; do password='pwgen -q' echo "cjh$x $password" >>
sambausers /bin/mkdir /home/cjh$x /usr/sbin/useradd -c "Student User" -d
/home/cjh$x -p $password -g students cjh$x /bin/chown -R cjh$x /home/cjh$x
/bin/chgrp -R students /home/cjh$x chmod 700 /home/cjh$x
/usr/bin/smbpasswd -a cjh$x $password x=$(expr $x + 1) done
Why do not you write a simple Perl script that does the job?


[ back to toc ]