Click to See Complete Forum and Search --> : Why isn't my counter working?!


fox1324
12-07-2005, 04:21 AM
Hey all, i'm still in training as far as perl and cgi are concerned, so please hear me out.

I downloaded a counter script from htmlgoodies.com and uploaded it to my site, (you can see the modified script at tcnj.edu/~jpnclub/cgi-bin/countcgi.cgi
the page i'm trying to get a count for is tcnj.edu/~jpnclub/index.html)

I modified the file according to the instructions provided with it- i telnetted into the server, went to the appropriate folder, used the "pwd" command to get the appropriate absolute path, did chmod 775 on all relevant files and folders. I confirmed that the perl program is located in the stardard place on the server (/usr/bin/perl). I've been going over this whole thing for hours, still no luck, i'm getting rather frustrated to say the least. any help would be greatly appreciated

thanks,
-nick

Nedals
12-07-2005, 01:33 PM
...you can see the modified script at cnj.edu/~jpnclub/cgi-bin/countcgi.cgi
You need to attach the script source code. All that link does is 'run' the script.

You should chmod to 755 not 775 (althought your script should still run).

Did you telnet in ACSII mode. If BINARY, it will not work.

That said, when I attempt to access the above link, I get a 'page not found' error which indicates the your script is NOT in the cgi-bin directory or it's not named 'countcgi.cgi'.

fox1324
12-07-2005, 02:17 PM
You need to attach the script source code. All that link does is 'run' the script.

You should chmod to 755 not 775 (althought your script should still run).

Did you telnet in ACSII mode. If BINARY, it will not work.

That said, when I attempt to access the above link, I get a 'page not found' error which indicates the your script is NOT in the cgi-bin directory or it's not named 'countcgi.cgi'.

my bad! at the end of the night, i changed the script's extension to .pl to see if that would make things work...it didnt. forgot to change it back, thats why you couldnt see the script. the full script is now available at http://www.tcnj.edu/~jpnclub/cgi-bin/countcgi.cgi .

the relevant lines of code are:
#!/usr/bin/perl
$minLen = 7;

#This is absolute path of the directory where the counter files are stored. Must be global-writeable.
$counterdir = "/home/acct3/jpnclub/www/counts";

EDIT: also, i chmod'd everything to 755, still no luck. and the script was uploaded in ascii mode. (as far as i can tell)

Nedals
12-08-2005, 01:04 AM
That is not a well written script. :(

#!/opt/local/bin/perl
This does not look correct, but it might be, and it should be on line 1. Check to be sure.

The link you provided should have run the script, not return the source code. Do you have any other cgi scripts running on your server?

Try this, using the more usual shebang line...

#!/usr/local/bin/perl

print "Content-type: text/plain\n\n";
print "Hello World\n";
exit;

save as 'test.cgi' in your cgi-bin directory and chmod 755
run with 'cnj.edu/~jpnclub/cgi-bin/test.cgi' in the address bar.

Then modify, and run, the script with the following..

#!/usr/local/bin/perl

use strict;
use CGI;
my $q = CGI->new();

print $q->header();
print "Hello World\n";
exit;

If that works, which it should, I'll explain and show you how to modify your script

Update:
I notice that in your last reply, the shebang line is as follows..
#!/usr/bin/perl

Which is it??

gozarca2
12-11-2005, 03:35 PM
i believe you will need perl5 to run cgi reliably. so on telnet do a "whereis perl" and "whereis perl5"...

your perl installations on your webserver and the apache server shoudl have cgi installed, but it may not... also, i think since your not actually running in the servers real cgi-bin, you may have to reference 'cgi-lib.pl'.