This shows you the differences between two versions of the page.
faq:web03 [2011/04/30 19:18] – created georg | faq:web03 [2011/04/30 19:19] (current) – georg | ||
---|---|---|---|
Line 1: | Line 1: | ||
< | < | ||
+ | [03] DO YOU HAVE A HIT COUNTER I CAN USE? | ||
+ | Yes, here is one that smj wrote in KORN shell which does basic locking. | ||
+ | | ||
+ | | ||
+ | |||
+ | $ cat > $HOME/ | ||
+ | |||
+ | Now copy and past the following into your terminal: | ||
+ | |||
+ | #!/bin/ksh | ||
+ | # smj's no nonsense house. | ||
+ | loop=0 | ||
+ | while [ -f .lck ] # while the lock file exists, | ||
+ | do | ||
+ | sleep 1 # sleep 1. | ||
+ | | ||
+ | if [ " | ||
+ | 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 [ " | ||
+ | then count=1 | ||
+ | else count=`expr $count + 1` # otherwise just increment | ||
+ | fi | ||
+ | echo $count > .cnt # write out the new count. | ||
+ | rm .lck # clear the lock | ||
+ | echo " | ||
+ | echo " | ||
+ | | ||
+ | ^D to close the ' | ||
</ | </ | ||
[[faq: | [[faq: |