Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
- The problem statement, all variables and given/known data:
Hi This is my first post.I am learning Unix and finding it difficult to get a handle on the scripting side of things. Thanks in advance
I am running Ubuntu Server 12.04 on vmware player
The 1st task is create user accounts and groups from a csv file i'll only list 2 lines from csv to give you the idea
File name stud.csv
id,firstname,surname,group,stage,status
d123,Joe,Bloggs,DT211,4,RE
c234,John,Bonham,DT228,4,EL
Task
For those students with status RE, create the account and
set the password to their StudentID.
o For those students with the status EL, create
the account without a password, and lock the
account
o Add each student to the group corresponding to
their class, i.e. DT228-4
o Add all students to the group student
o For each student with a d student number, add
them to the user group direct
o For each student with a c student number, add
them to the user group cao
with the help of several sites and a friend i managed to complete this part, its the next part i'm stuck on
Write and test bash script(s) to delete the accounts and any traces of the
accounts listed in the .csv file above. This includes
o the removal of the specified account
o the deletion of the user�s home directory
o the deletion of the user groups once all the
above accounts have been deleted
- Relevant commands, code, scripts, algorithms:
The following is the script for the first part
#!/bin/bash
while IFS=, read id firstname surname group stage status
do
3. The attempts at a solution (include all code and scripts):
This is what i tried. I just started with one group of users to see if that worked but no joy.
#!/bin/bash
while IFS=, read id firstname surname stage status
do
sid=`echo $id � cut -c1`
if [ $id == "d" ]
then userdel -r
fi
if [ $group == "DT211" ]
then userdel -r
fi
done < stud.csv
I tried a script from this forum titled
Using userdel -r in a script? To delete multiple users.
but that didnt work either, but i think he was trying to delete users from a file, i want to delete them from the directory
Thanks again
- Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Dublin Institute Technology, Dublin, Ireland, Mark Deegan, DT768
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).