[ SDF Public Access UNIX System .. Est. 1987 ]

join welcome faq status members projects store tour gopher abuse dialup dsl minecraft social
tilde nihongo europa webmail gallery usermap teach irc tutorials software telnet ssh

[03] DO YOU HAVE A HIT COUNTER I CAN USE?

     Yes, here is one that smj wrote in KORN shell which does basic locking.
    
     Follow these steps (after you've run mkhomepg):

     $ cat > $HOME/html/counter.cgi

     Now copy and past the following into your terminal:

#!/bin/ksh
# smj's no nonsense house.
loop=0                             # set the while counter.
while [ -f .lck ]                  # while the lock file exists,
do
 sleep 1                           # sleep 1.
 loop=$((${loop} + 1))             # then increment the counter.
 if [ "$loop" -gt "10" ]           # if it increments beyond 10,
  then rm -f .lck                  # clear the lock file.
 fi
done
touch -f .lck                      # create a new lock file.
count=`cat .cnt`                   # get the current count.
if [ "$count" = "" ]               # if its empty,
 then count=1                      # start the counter over.
 else count=$((${count} + 1))      # otherwise just increment
fi
echo $count > .cnt                 # write out the new count.
rm .lck                            # clear the lock
echo "Content-type: text/html"     # make some html noise.
echo
echo "[$count]"
    
     ^D to close the 'cat' and run 'mkhomepg -p' to set proper permissions.

[back]


©1987-2065 SDF Public Access UNIX System, Inc. 501(c)(7)
(this page was generated using ksh, sed and awk)