Welcome to MobyThreads.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in
All support for the MobyThreads Threaded phpBB MOD can now be found on welsolutions at this forum

Newbie: Web counter [long ish]

 
   Web Hosting and Web Master Forums (Home) -> Apache RSS
Next:  How do I use the Win32DisableAcceptEx directive p..  
Author Message
user2767

External


Since: May 02, 2004
Posts: 2



(Msg. 1) Posted: Sun May 02, 2004 4:51 pm
Post subject: Newbie: Web counter [long ish]
Archived from groups: alt>apache>configuration (more info?)

Hi,

I've got Apache running fine on a Win XP machine & all my static pages are
working fine. The CGI test pages work ok, but I cant seem to get a web
counter to work:

I've got a test shtml page "countertest.shtml" that looks like this:

<html>
<head>
<title>Basic Hit Counter Example</title>
</head>

<body>
<br>
<br>
<br>
<p>You are person number
<!--#include virtual="/cgi-bin/counter.pl" -->
to view this demo!</p>
</body>
</html>

counter.pl is indeed in the /cgi-bin directory & looks like this:

#!\indigoperl\bin\perl

# the path for the log file
$logpath = "count.dat";

# digits for the counter
$pad = 5;

# opens the log file for reading, will be created if none exists.
open (LOG, "$logpath");
@file = <LOG> # an array of the file contents
close(LOG);

$count = $file[0]; # the count value is the first line in the file, i.e.
$file[0]
$count++; # increments the counter value

open (LOG, ">$logpath"); # opens the log file for writing
flock(LOG, 2); # file lock set
print LOG "$count\n"; # prints out the new counter value to the file
flock(LOG, Cool; # file lock unset
close(LOG);

# sets the leading zeros padding for the counter
$pad = "%.$pad"."d";
$count = sprintf($pad, $count);

# prints out the counter
print "Content-type: text/html\n\n";
print "$count";

The web page gives:
You are person number [an error occurred while processing this directive] to
view this demo!

count.dat isn't created & the error log tells me:

unable to include "/cgi-bin/counter.pl" in parsed file
c:/indigoperl/htdocs/countertest.shtml

This is my first attempt at CGI & am at a loss, I'm sure I doing something
daft, any help much appreciated.

TIA

--
oOo
Andy Stevenson
http://home.freeuk.net/stevenso/
"A little bit of pain never hurt anyone!" Sam, aged 11

 >> Stay informed about: Newbie: Web counter [long ish] 
Back to top
Login to vote
user2767

External


Since: May 02, 2004
Posts: 2



(Msg. 2) Posted: Sun May 02, 2004 6:40 pm
Post subject: Re: Newbie: Web counter [long ish] [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Andy Stevenson wrote:
[snip]

Bad form to reply to my own post I know, but I've sorted it now.

Amazing the difference a semi-colon will make!

@file = <LOG> # an array of the file contents

should have been

@file = <LOG>; # an array of the file contents

--
oOo
Andy Stevenson
http://home.freeuk.net/stevenso/
"A little bit of pain never hurt anyone!" Sam, aged 11

 >> Stay informed about: Newbie: Web counter [long ish] 
Back to top
Login to vote
hans1

External


Since: Mar 29, 2004
Posts: 672



(Msg. 3) Posted: Sun May 02, 2004 8:23 pm
Post subject: Re: Newbie: Web counter [long ish] [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Andy Stevenson" <no.DeleteThis@chance.com> schreef in bericht
news:W86lc.27$XP4.6@newsfe6-win...
 > The web page gives:
 > You are person number [an error occurred while processing this directive]
to
 > view this demo!
 > count.dat isn't created & the error log tells me:
 > unable to include "/cgi-bin/counter.pl" in parsed file
 > c:/indigoperl/htdocs/countertest.shtml
You should have made more explicitely reference to IndigoPerl Wink
BTW I prefer Perl-5.8-win32-bin-0.7.exe via
<a style='text-decoration: underline;' href="http://www.apache.org/dyn/closer.cgi/perl/win32-bin/," target="_blank">http://www.apache.org/dyn/closer.cgi/perl/win32-bin/,</a> it comes with ssl
support and more perl modules and

Just one line above you'll most likely find in your error.log
'the system cannot find the path specified. : couldn't spawn child process:
C:/indigoperl/apache/cgi-bin/counter.pl'

 > This is my first attempt at CGI & am at a loss, I'm sure I doing something
 > daft, any help much appreciated.
Might be too cryptic -and common too-: path to perl(.exe) on line 1 of
counter.pl is incorrect.
(Furthermore line 11 and 15 lack a semicolon; line 15 seems redundant)
Please make the following changes to counter.pl:
( - original line to be remove + new line to be inserted)
1 - #!\indigoperl\bin\perl
1 + #!\indigoperl\perl\bin\perl
11 - @file = <LOG> # an array of the file contents
11 + @file = <LOG>; # an array of the file contents
15 - $file[0]
15 + #[this line is blanc]

Enjoy,

HansH<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Newbie: Web counter [long ish] 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Need Text mode hit counter for Apache on Debian box - Hello, I have an Apache server running on a Debian Linux box and want to get a web page hit counter program that does not need "graphic" (X-windows) to run. I have searched the www with Google and found quite a few "free" hit counte...

too long processes - Hello, My server is running apache 1.3 and for severals weeks some processes don't want to stop. When i send a 'top' command i have more than 18 processes running and all are httpd. moreover this processes are running during long long time and my whole....

Long domain names - Hi, I've got URLs like this one: users.mem.domain.com . I've created a virtualhost with the serveralias *.mem.domain.com . I want to map * to a seperate dir. I've tried to use mod_vhosts, but it won't see the very first part of it. And now I'm..

Long log file with Apache - Hello, I have an apache server which hosts a dozen of web sites. Each web site is configured with two files : - site1.access (which contain the <Directory>) - site1.srm (which contain the DocumentRoot) these two files let me choose the web director...

Eliminating long access.log entries - My webalizer cron job was not running because I had a few entries in my access.log file of \x90\x90\x90, which just ran on forever. Webalizer was complaining of oversized log records. This just appears to be a ASP buffer overflow exploit. Is there any wa...
   Web Hosting and Web Master Forums (Home) -> Apache All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]