#!/bin/bash # Script to log time in and out MINPARAMS=1 LOG_DIR=/home/justin NET_DIR=/home/justin/Network/G/DOCS/ E_NOARGS=65 E_BADARGS=66 E_XCD=67 TESTLOG=testtimelog LIVELOG=jplog-$(date +%Y%m).txt # Test for arguments if [[ -z "$1" ]] then echo "Usage: punch [OUT | LUNCH]" exit $E_NOARGS fi # Test for proper syntax, set BACK variable if [[ $1 = OUT ]] then BACK=IN elif [[ $1 = LUNCH ]] then BACK=LUNCH_IN else echo "Usage: punch [OUT | LUNCH]" exit $E_BADARGS fi # Test for testing or live if [[ $2 = -t ]] then LOG=$TESTLOG else LOG=$LIVELOG fi # Go to home dir cd $LOG_DIR # Test if in home dir if [[ `pwd` != $LOG_DIR ]] then echo "Can't change to $LOG_DIR" exit $E_XCD fi # Create monthly log if needed touch $LOG # Log time & date # FFR, variables used are: %F - full ISO date %t - tab %R - 24h timestamp date +%F%t%R%t$1 >> $LOG_DIR/$LOG # launch screensaver and wait for login xlock -mode biof & wait # upon login, log time date +%F%t%R%t$BACK >> $LOG_DIR/$LOG # display last 5 lines of log, copy real logfile to network tail -n 5 $LOG cp $LOG_DIR/$LIVELOG $NET_DIR ### Working area for modifications ## display difference between real logged time and expected time # # # exit