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

In reply to execute perl script in html by alpal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.