All pastes #730805 Raw Edit

Mine

public text v1 · immutable
·published 2007-10-09 15:10 UTC
rendered paste body
#!/bin/bash

# Script to log time in and out
MINPARAMS=1
LOG_DIR=/home/justin
NET_DIR=/home/justin/Network/G/DOCS/DP_MIS/JPURDY/.
E_NOARGS=65
E_BADARGS=66
E_XCD=67
TESTLOG1=testtimelog1
TESTLOG2=testpayperiod2
LIVELOG1=timelog
LIVELOG2=payperiod

# Test for arguments
if [[ -z "$1" ]]
then
        echo "Usage: punch [OUT | LUNCH | VACATION | HOLIDAY]"
        exit $E_NOARGS
fi

# Test for proper syntax, set BACK variable
if [[ $1 = OUT ]]

then
        BACK=IN
elif [[ $1 = LUNCH ]]
then
        BACK=LUNCH_IN
elif [[ $1 = VACATION ]]
then
        BACK=VACATION_IN
elif [[ $1 = HOLIDAY ]]
then
        BACK=HOLIDAY_IN
else
        echo "Usage: punch [OUT | LUNCH | VACATION | HOLIDAY]"
        exit $E_BADARGS
fi

# Test for testing or live
if [[ $2 = -t ]]
then
        LOG1=$TESTLOG1
        LOG2=$TESTLOG2
else
        LOG1=$LIVELOG1
        LOG2=$LIVELOG2
fi

# Insert date for vacation/holiday
#if [[ $1 = VACATION ]]
#then

# 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 logs if needed
touch $LOG1
touch $LOG2
# Log time & date to timelog
# FFR, variables used are: %F - full ISO date %t - tab %R - 24h timestamp
date +%F%t%R%t$1 >> $LOG_DIR/$LOG1
# Log epoch to payperiod
date +%s%t$1 >>$LOG_DIR/$LOG2
# launch screensaver and wait for login

xlock -mode biof &
wait

# Display current time total
if [[ $BACK = IN ]]
then
        awk -f $LOG_DIR/timecount.awk payperiod
fi

date +%F%t%R%t$BACK >> $LOG_DIR/$LOG1
date +%s%t$BACK >> $LOG_DIR/$LOG2

# display last 5 lines of log, copy real logfile to network

tail -n 5 $LOG_DIR/$LOG1
cp $LOG_DIR/$LOG1 $NET_DIR

exit