CS476/576

Assignment #1

Due Midnight, Wednesday Oct 6, 2010


Write a shell script (in any shell you like) with the following descriptions:

NAME

ualist -    user activity list.

 

SYNOPSIS

ualist   [<file>]

DESCRIPTION

This shell script is used to generate an up-to-date UNIX accounts user activity list.

The information about each user in the list is:

 

1)    User group

2)    Active/nonActive flag.

3)    User login

4)    User name

 

The list is sorted by these fields.

 

Unix  group  file  (produced by the command ypcat group) lists the various Unix groups names

and their assigned group numbers. For example, at the CS dept at ODU the output contains:

 

student:*:21:

faculty:*:13:

grad:*:22:

staff:*:10:

guest:*:31:

 

Unix  password file (produced by the command  ypcat passwd) have one line for each user. For example, at the CS dept at ODU the output contains:

 

thristov:JPSijeRq4jB82:783:21:tihomir hristov:/home/thristov:/usr/local/bin/tcsh

wahab:stg/i.0xxJ1zU:51:13:Hussein Abdel-Wahab:/home/wahab:/usr/local/bin/tcsh

hshi:h8fj6/06qHSmg:189:22:Hui Shi:/home/hshi:/usr/local/bin/tcsh

robin_c:l5zLZCKUTmFNw:15:10:Chris Robinson:/home/robin_c:/bin/bash

tisenhou://PGVHc7vi9lI:1470:31:tom isenhour:/home/tisenhou:/usr/local/bin/tcsh

 

 

If a user recently logged in to any of the department fast machines (produced by the command host fast) he/she is considered to be an Active. You may use the commands ssh and last, e.g:

       % ssh  <fasthost>  last -1 <user>

For example, to find if users wahab and tisenhou have recently logged to the fast host vega:

% ssh vega last -1 wahab

    wahab     sshd         capella.cs.odu.e Sun Sep 12 13:28 - 13:28  (00:00)

% ssh vega last -1 tisenhou

    wtmp begins Wed Apr 30 12:09

Thus the output of the ualist script for  users wahab and tisenhou  will be:

faculty Active :wahab: Hussein Abdel-Wahab

guest nonActive :tisenhou: tom isenhour

To avoid typing your password when ssh to login a fast host use:

% /home/cs476/sshLogin.csh

 

If the user provide <file> as an argument, the file should contain a subset of the password file.

For testing purposes using a file is recommended.