#!/bin/sh
#counter file must be chmod 666
counter=../cgi-bin/counter
echo "Content-Type: text/html"
echo ""
read acces < $counter
acces = 'expr $acces+1'
echo $acces
echo $acces > $counter
counter is a text file which only value inside is 1.
I want to increase the value of file counter by 1 and store it back to file
counter.
when I run it in shell, it always tell me: command acces not found.
why?
thx
s**i 发帖数: 30
2
if in bash
acces=`expr $acces + 1`
you should use back quote and if you want to set number to a variable
in this form there should be no blank before and after the '=' and there
should be space before and after the '+'
【在 s*****i 的大作中提到】 : #!/bin/sh : #counter file must be chmod 666 : counter=../cgi-bin/counter : echo "Content-Type: text/html" : echo "" : read acces < $counter : acces = 'expr $acces+1' : echo $acces : echo $acces > $counter : counter is a text file which only value inside is 1.