Hi all,
I'm sure a couple people will laugh at me for not being able to figure this out, but I think I really am stuck. I'm trying to get my feet wet with cgi scripts and whatnot, so I say HEY, why not try making a counter for my webpage?? So I start. I made a really simple script that seems to work fine. It is:
#!/perl/bin/perl.exe
open FILE, "visit.txt" or die "Screwed it up...Can't open for read..."
+;
$counter = <FILE>;
close FILE;
$counter = $counter + 1;
open FILE, ">visit.txt" or die "Screwed it up...Can't open for write..
+.";
print FILE $counter;
close FILE;
chomp ($counter);
print "Content-type: text/html\n\n ";
print "<br>$counter<br>";
I also have a visit.txt in the cgi-bin directory that stores just a single number.
I can actually go to http://localhost/cgi-bin/counter.pl and it displays the number of users, and every time you refresh the number goes up, which is exactly what I wanted!
The problem here, is that when I try to get the script to execute inside a webpage, nothing happens. In the html I used
<!--#exec cgi="/cgi-bin/counter.pl"--> but the script never actually executes. I even tried using all combinations of the link, like "..cgi-bin/counter.pl" "counter.pl" etc.
I tried using
<!--#echo var="blab labl ablabla bl ablabl ablabla"-->to see if any of these SSI commands will execute, and still nothing happens. I also tried the cmd one too, and still nothing. I tried naming the html as a .shtm as well, I read somewhere that that needed to be done, but still nothing.
I made the .htaccess file in my html directory, but apparently something still isn't configured correctly.
I just need to be able to have the script automatically execute as the page is loaded. This is sort of my window to getting more involved in perl and cgi scripts, but I can't get it to work! I've slaved for about 3 days now with no progress, so I thought the folks at perlmonks might be able to help or maybe just point me in the right direction.
Thanks!
Alan