creating user accounts from file

Bash Script

Posted 03 December 2010 - 11:26 AM

Hi there I'm simulating hosting server and I have a question. I have a file called Users.txt and when a user registers this file is appended in the following format - $username:$password . So my goal is to create bash script that reads the file line by line and adds the new Linux users. The code also needs to create a home directory for each user.

So this is what I got by now but something is missing...

#!/bin/bash
IFS.OLD=&IFS
IFS=$'\n'
for entry in `cat /home/student/public_html/Users.txt`
do
IFS=:
for i in &entry
do
useradd $i -p #I'm not sure how to include the $password here...
done
done