#!/bin/sh - # Checklog script # Omer Rana # copyright : University of Wales, Cardiff logs=/home/scmofr/public_html/os/access-file number=1 refdir=`pwd` # Does the log file exist if [ ! -f $logs ]; then echo "Log file does not exist" exit 1 fi # ---------------------------------------- # What does the user want if [ "$1" = "hosts" ]; then grep "$2" $logs | awk '{print $1}' | uniq > templist lines=`wc templist | awk '{print $1}'` while [ "$number" -le "$lines" ] do hostip=`sed -n "$number p" templist` `nslookup -sil "$hostip" | grep -i "name" | awk '{print $4}' >> lookup` number=`expr $number + 1` done echo " " echo " Host IP Address " echo " --------------- " paste templist lookup rm lookup rm templist exit 1 fi # -------------------------------------- if [ "$1" = "full" ]; then grep "$2" $logs | uniq | more exit 1 fi # -------------------------------------- # Otherwise echo "usage: checklog [hosts|full] User_Name"