#! /bin/sh # leo - LOG ENTRY ORGANIZER, puts a message into a daily monthly logfile. # USAGE: leo this is a test <-- single line entry # leo -v <-- vi session entry # cat /etc/motd | leo <-- standard input entry # leo -l <-- list the current log file # leo -e <-- edit the current log file # Written by kirk Waingrow 11/10/93 # Inspired by Hal Pomeranz, QMS Inc. who wrote PLOD - Personal LOgging Device # Revision 1.2 - added listing and editting of log files ID=`/usr/bin/logname` # User ID DPATH="/home/kwaingrow/leo" # Data path of log entries TMP="/usr/tmp" # Tmp files to be stored DATE=`date '+%m/%d/%y, %H:%M --'` # Format data for log entry FILE=`date | awk '{ printf("%s%d\n", $2, $3) }'` # Get the file name yr=`date +%y` FILE=`echo $yr$FILE` VI=/bin/vi # Which editor to use ARG="$*" # Store any arguments. if [ ! -d "$DPATH" ]; then # If data path doesn't exist mkdir $DPATH # make it. chmod 700 $DPATH fi if [ ! -f "$DPATH/$FILE" ]; then # If log file doesn't exist cat /dev/null > $DPATH/$FILE # set it up. chmod 700 $DPATH/$FILE fi if [ -n "$ARG" ]; then # Check for argument if [ `echo $ARG | cut -c1` = "-" ]; then ARGL=`echo $ARG | cut -c2` case $ARGL in v) $VI $TMP/leo.$ID if [ -f "$TMP/leo.$ID" -a -n "$TMP/leo.$ID" ]; then # Check if entry echo >> $DPATH/$FILE # Check if entry was echo $DATE >> $DPATH/$FILE # saved. If so log it. cat $TMP/leo.$ID >> $DPATH/$FILE rm -f $TMP/leo.$ID else # If not saved remove it. rm -f $TMP/leo.$ID fi;; l) clear; cat $DPATH/$FILE | more;; e) $VI $DPATH/$FILE;; esac else # If not VI session log the echo >> $DPATH/$FILE # it as a line entry. echo $DATE >> $DPATH/$FILE echo "$ARG" >> $DPATH/$FILE fi else echo >> $DPATH/$FILE # If no arguments then echo $DATE >> $DPATH/$FILE # consider it to be standard awk '{ print }' >> $DPATH/$FILE # in. fi