I want to create a simple little hit counter in shell. I figure I will store a value in a file. Read it when the page is accessed using SSI and write a new value over the top. Trouble is, I am useless at scripting. So far what I have is this:
echo $NUM >> counter.dat
but that seems to be concatenating the file.
How do I overwrite?
Thanks in advance.
Thankyou. Now that is working fine when I execute the script manually from a terminal window. But it isnt working when I call it through my web???? Its not giving any errors, it just doesnt seem to be writing to the file. Its not to do with refresh as I have checked the datafile.
echo $NUM > ../htdocs/mystuff/counter.dat
<b>Welcome to my world!</b><br>
You are visitor number: <br>
<!--#exec cgi="/cgi-bin/counter.cgi" -->
<!--#include file="counter.dat" -->
<!--#config timefmt="%d/%m/%y" -->Today's Date:
IM guessing its something to do with pathnames
dont know how to represent this dir structure here. cgi-bin and htdocs are on the same level.
>cgi-bin dir > counter.cgi
>htdocs dir > my stuff dir > welcome.shtml, counter.dat