Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Prof. Orlando Karam maintains an Ubuntu Linux server for his class. Every semest

ID: 3809104 • Letter: P

Question

Prof. Orlando Karam maintains an Ubuntu Linux server for his class. Every semester he needs to create an account for each student. It takes a lot of time to create these accounts one by one interactively. So he decides to automate the process by writing a script.
You are Orlando’s TA and volunteered to complete the task. Please propose a solution and write a script (either Bash or Perl) to implement your solution. Basic requirements:
The script reads from a CSV file for student information (exported from Excel). The file is made up of the lines like this: Jack,Zheng,jzheng3 //[first name],[last name],[campus email id] Mark,Cuban,mcuban2 …
Please make up your own CSV file (with at least 5 students/lines) for testing purpose.
Every student is assigned a common initial password (you will determine the password).
Students are required to change their passwords at first login.
All student accounts should be assigned to a “student” group. This group already exists in the system (you need to create this group first for testing purpose).
Make some other assumptions if not specifically required. Reminder: you will and should do some research on how to read and parse CSV files, and how to process passwords programmatically

Explanation / Answer

#!/bin/bash
input="/path/to/your/input/file.cvs"
# Set "," as the field separator using $IFS
# and read line by line using while read combo
while IFS=',' read -r f1 f2 f3
do
echo "$f1 $f2 $f3 "
f4=$f1$f2
/usr/sbin/useradd -G Student $f4
pwd=kalam$(echo "$f3")
echo $pwd | passwd $f4
chage -d 0 $f4
done < "$input"

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote