F.N.G.
02-03-2003, 12:17 PM
Hi,
I'm new to cgi, and am getting no results with a counter-script that I found in this very forum: "" (http://www.codingforums.com/showthread.php?threadid=11826&highlight=counter)
#!/usr/bin/perl
print "Content-type: text/html\n\n";
$tempcount = 0;
while($tempcount < 8)
{
$tempcount++;
if(-e "lock/myfile.lok")
{
sleep 2;
}
else
{
open (LOCK,">>lock/myfile.lok");
close LOCK;
open (COUNTER,"<counter.fil");
$count = <COUNTER>;
close COUNTER;
$count++;
open (COUNTER,">counter.fil");
print COUNTER ($count);
close COUNTER;
unlink "lock/myfile.lok";
last;
}
}
------------------------------------------
HERE IS MY TEST PAGE:
<html><head><title>_</title></head>
<body style="background:#ffffff;
font-face:arial;
font-size:10px;
color:#cccccc">
<div style="position:absolute;top:2px;left:5px">
count = <!--#exec cgi="cgi-bin/counter.cgi"-->
</div>
<center>
<br /><br /><br /><br /><br /><br />
T E S T . . .
</center>
</body></html>
THESE ARE THE INSTRUCTIONS FROM THE SERVER:
------------------------------------------------------
To use cgi, create a cgi-bin in your home directory. Upload
.cgi and .pl files into that folder. Remember that they must
be made executable before they will work.
Some cgi\'s need a full path name to work. Add /home/username
to the path name.
perl version 5 = /usr/local/bin/perl
-----------------------------------------------------
THIS IS WHAT i HAVE IN THE CGI-BIN:
-----------------------------------------------------
counter.cgi (chmod-755) & counter.fil (chmod-777)
-----------------------------------------------------
Nothing is happening with the counter... the page displays ' count = (nothing) ' rather than ' count = # '
If anyone can see what I am doing wrong, please let me know.
I'm new to cgi, and am getting no results with a counter-script that I found in this very forum: "" (http://www.codingforums.com/showthread.php?threadid=11826&highlight=counter)
#!/usr/bin/perl
print "Content-type: text/html\n\n";
$tempcount = 0;
while($tempcount < 8)
{
$tempcount++;
if(-e "lock/myfile.lok")
{
sleep 2;
}
else
{
open (LOCK,">>lock/myfile.lok");
close LOCK;
open (COUNTER,"<counter.fil");
$count = <COUNTER>;
close COUNTER;
$count++;
open (COUNTER,">counter.fil");
print COUNTER ($count);
close COUNTER;
unlink "lock/myfile.lok";
last;
}
}
------------------------------------------
HERE IS MY TEST PAGE:
<html><head><title>_</title></head>
<body style="background:#ffffff;
font-face:arial;
font-size:10px;
color:#cccccc">
<div style="position:absolute;top:2px;left:5px">
count = <!--#exec cgi="cgi-bin/counter.cgi"-->
</div>
<center>
<br /><br /><br /><br /><br /><br />
T E S T . . .
</center>
</body></html>
THESE ARE THE INSTRUCTIONS FROM THE SERVER:
------------------------------------------------------
To use cgi, create a cgi-bin in your home directory. Upload
.cgi and .pl files into that folder. Remember that they must
be made executable before they will work.
Some cgi\'s need a full path name to work. Add /home/username
to the path name.
perl version 5 = /usr/local/bin/perl
-----------------------------------------------------
THIS IS WHAT i HAVE IN THE CGI-BIN:
-----------------------------------------------------
counter.cgi (chmod-755) & counter.fil (chmod-777)
-----------------------------------------------------
Nothing is happening with the counter... the page displays ' count = (nothing) ' rather than ' count = # '
If anyone can see what I am doing wrong, please let me know.