#!/bin/csh -f
#  Copyright 1997 Yukinori Koike  Ver 1.4
#
set LOGFILE=$1
set FILENAME = $LOGFILE:r
# Lock File
set LOCKFILE = $FILENAME.lck
if ( -e $LOCKFILE ) then
	sleep 5
	rm -f $LOCKFILE
endif
cp /dev/null $LOCKFILE
# Log File
echo "{+}" >> $LOGFILE
echo "{BDATE:`date '+20%y%m%d%H%M%S'`}" >> $LOGFILE
if ($?REMOTE_HOST == 1) then
	echo "{HOST:$REMOTE_HOST}" >> $LOGFILE
endif
if ($?REMOTE_ADDR == 1) then
	echo "{IP:$REMOTE_ADDR}" >> $LOGFILE
endif
if ($?HTTP_USER_AGENT == 1) then
	echo "{BROWSER:$HTTP_USER_AGENT}" >> $LOGFILE
endif
if ($?HTTP_REFERER == 1) then
	echo "{URL:$HTTP_REFERER}" >> $LOGFILE
endif
# Counter FIle
grep '{+}' $LOGFILE | wc -l > $FILENAME.cnt
rm -f $LOCKFILE
