January 2004
Intermediate to advanced
368 pages
7h 25m
English
One popular element of many web pages is a page counter that increments each time a request for the page in question is served. A quick glance at the counter value then lets you see how popular your pages are and whether they're seeing lots of visitors. While counters aren't typically written as shell scripts, that doesn't mean it can't be done, and we'll throw caution to the wind and build it ourselves!
The fundamental challenge with this particular script is that there's a possible race condition, a situation in which two people visit the page simultaneously and each of the counter scripts steps on the other when writing to the data file. You can try to solve the race condition within the script ...
Read now
Unlock full access