Hello all,

  I am new to the list and joined in hopes that someone might be able to help me with a problem I’m having with what seems to be a simple counter script.  In the interest of full disclosure, I must confess that I am not really a programmer, but am trying to research this problem which my ISP seems unable (so far) to figure out.  Whatever info I can get I will pass on to my ISP tech.  I will try to provide as much info here as I know:

 

On the pages of my web site, I have run a simple perl script intended to place a counter on each page visited.  The script worked great on my previous ISP’s web server, but now it is not working after I moved to a new provider.  I have made sure that the files are CHMODed to 755 and even tried 777, including the directory.  In my error log files, I get the following error:

 

“Premature end of script headers”

 

Like I said, this counter script worked fine on my previous web sever.  The main difference seems to be that my previous provider used Perl Version 5.004 (I think), but instead of using Perl Version X.XXXX, my new provider used mod_perl 1.27 with Apache 1.3.2.7  (the use of mod_perl is why I thought someone here might be able to help)

 

Below is the code that is not working:

 

START QUOTE

#!/usr/bin/perl

#

#     COUNTER.CGI

#

#     This counter script is meant to be used for a site-wide setup, although

# it can certainly be used by individuals if they want counters on their own

# pages.

#

#     For an explanation of how this script works and how to make sure it

# will work with your server, see: 

# http://web.sau.edu/~mkruse/www/info/ssi.html

#

#     To install this script:

# 1.  Move it to its own directory, like /cgi-bin/counters/

#     It will create many files in the dirctory where it is located, so put

#     it somewhere off on its own.

# 2.  make it executable (chmod a+x counter.cgi)

# 3.  make the directory where it is at world-writable (so the server can

#     update the counter files).

# That's it!

# Call it as you would any other server-side-include

#

print "Content-type: text/html\n\n";

($PAGE = $ENV{'DOCUMENT_URI'}) =~ s/\//_/g;

if (!(-e $PAGE)){open(NEW,"> $PAGE");print NEW "0";close(NEW);exit(0); }

open(COUNTER,"+< $PAGE");

flock(COUNTER,2);

$_=<COUNTER>;

seek(COUNTER,0,0);

$_++;  print;  print COUNTER;

flock(COUNTER,8);

close(COUNTER);

 

END QUOTE

 

I would greatly appreciate any insights anyone might be able to provide to help solve this problem,

 

Thanks,

Cy

Reply via email to