I'm trying to add users to the system from a file. The file looks exactly like this:
user@domain.com password 1
user2@domain.com baddpassword 2
The numbers are their IDs. Its coming from a mysql db and I need to do something with those variables too so I need 4 variables. The USER, PASS, FIRSTID (being 1) and LASTID (being the last ID of the mysql dump in this case, 2. This is considering more than 2 entries at a time)
So far what I have is this:
for USER in `cat /root/users_w_pass | sed -n '1!p' | awk -F@ '{print $1}'`
do
for PASS in `cat /root/users_w_pass | sed -n '1!p' | awk -F ' ' '{print $2}'`
do
useradd $USER -d /home/$USER -m -s /home/$USER.sh
echo "$USER:$PASS" | chpasswd
done
done`
When running this, the password does not get added to the corresponding user and I have no idea on how I am supposed to do that since I thought it would work but I can see how it doesn't. Also I need to do a lot more than just add them to the system, I am creating files and assigning ACLs for each, so running newusers
on a file won't work here, especially that there is a third column as well.