GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — shell-script/075-counter.sh at master · srinivart/shell-script

Expand file tree

/

075-counter.sh

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
executable file
·
49 lines (40 loc) · 1.18 KB
/

075-counter.sh

Copy path

File metadata and controls

executable file
·
49 lines (40 loc) · 1.18 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
# counter - a simple text-based page counter, with appropriate locking
myhome="/home/taylor/web/wicked/examples"
counter="$myhome/counter.dat"
lockfile="$myhome/counter.lck"
updatecounter="$myhome/updatecounter"
# Note that this script is not intended to be called directly from
# a web browser so it doesn't use the otherwise obligatory
# content-type header material.
# ascertain whether we have lockf or lockfile system apps
if [ -z $(which lockf) ] ; then
if [ -z $(which lockfile) ] ; then
echo "(counter: no locking utility available)<br>"
exit 0
else # proceed with the lockfile command
if [ ! -f $counter ] ; then
echo "0" # it'll be created shortly
else
cat $counter
fi
trap "/bin/rm -f $lockfile" 0
lockfile -1 -l 10 -s 2 $lockfile
if [ $? -ne 0 ] ; then
echo "(counter: couldn't create lockfile in time)"
exit 0
fi
$updatecounter $counter
fi
else
if [ ! -f $counter ] ; then
echo "0" # it'll be created shortly
else
cat $counter
fi
lockf -s -t 10 $lockfile $updatecounter $counter
if [ $? -ne 0 ] ; then
echo "(counter: couldn't create lockfile in time)"
fi
fi
exit 0
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.