In this Lab you will create your own version of a popular Linux utility, who. Your version, who2 will add two new pieces of information to the output of who, which may be useful here in our environment at CCSF. The two pieces of in formation are:
Here is the sample output of who and the corresponding output of who2:
for the who output:
bwong20 pts/3 2016-11-26 15:10 (220.127.116.11) smusarra pts/7 2016-11-26 13:24 (18.104.22.168) uwostner pts/14 2016-11-26 14:37 (22.214.171.124) uwostner pts/25 2016-11-22 13:43 (126.96.36.199)
who2 outputs the following
S bwong20 pts/3 2016-11-26 15:10 (188.8.131.52) [Benji] S smusarra pts/7 2016-11-26 13:24 (184.108.40.206) F uwostner pts/14 2016-11-26 14:37 (220.127.116.11) [Ulf Wostner]
The passwd entries for these users are below:
uwostner:x:326:208:Ulf Wostner,Cyberspace,:/users/uwostner:/bin/bash bwong20:x:30663:506:Benji,I don't have an office!,,:/students/bwong20:/bin/bash smusarra:x:38498:506:smusarra:/students/smusarra:/bin/bash
You can decide if someone is a student or faculty by looking at the passwd entry's gid field and comparing it to the gid of the groups STUDENT_GROUP and FACULTY_GROUP which are variables set in the starting version of your shell script. See the labs directory beneath our public work area on hills for who2.
This script is pretty easy if, after translating STUDENT_GROUP and FACULTY_GROUP to their corresponding group ids (which must be done in code, not by entering the group id by hand), you start with a while read loop that reads a line at a time from the output of who (possibly with some additional processing) and process each line.
Turn in who2 when you are finished on Canvas