Click to See Complete Forum and Search --> : Another newbie needing help with counter.pl
jasnjohn
09-20-2003, 10:50 AM
Well, I've tried various things to get Matt's Counter.pl working, and just can't get it displayed on my webpage.
The script itself works, as I can run it directly from the browser simply with the address to the script.
I had a bit of help from the server guys with the server path to the data file that counter.pl needs to open and write to, and by running the script manually, it works.
I think the problem lays with my html file calling the script.
I can confirm that the address to the data text file the perl writes to is:
/usr/local/psa/home/vhosts/??????mydomain????/cgi-bin/counter/counter.txt"
My perl script "counter.pl" is located directly in the cgi-bin folder, therefore, I need to know how to call this from my html file. I've tried the following (and many other variants) with no success:
<!--#exec cgi="/usr/local/psa/home/vhosts/mydomain.com/cgi-bin/counter.pl"-->
No joy!
When the server guys helped out with the script, they also dumped counter.cgi into the cgi-bin folder, so, I even tried addressing that, but no joy.
Can anyone see what's the problem?
I have SSI activated on the server, the files and folders all have the right permissions set, I'm going nuts over what was supposed to be one of the easiest scripts I could get started with.
Thanks,
John
...try calling it as an image...
<img src="http://www.your.host.com/cgi-bin/counter.pl">
jasnjohn
09-20-2003, 10:22 PM
That didn't work. I know Matt's scripts have both graphic and text counters, mine is the text counter.
If you know this script, I have commented out the @invalid_uri, so there shouldn't be any reason the script wont let my index.html page call it.
Crazily, I can't even call a script that the server guys put up as a test. I can go to it directy in my address bar and it will work, a sort of
'hello world!" script. If I wanted to call the script from my html, it just won't work.
Does it sound like the path I'm using is no good?
MotherNatrsSon
09-21-2003, 01:22 AM
Try this:
Look at the read me for the script HERE (http://www.scriptarchive.com/readme/counter.html#how_to_call)
It says: I accidentally left out the part about how to call this program in my previous release. You simply can call this program like you would call any other image or background picture. Examples are shown below:
<img src="http://www.your.host.com/path/to/counter.pl">
That will give you the standard counter image, andyou can put <center> tags around it or position it however you like on your web page.
So based on that it would be:
<img src="http://yoursite.com/cgi-bin/counter.pl>
If that does not work you have a different problem.
Do you have your cgi-bin in another folder other than your root directory? That would add another level to the path. You should have your cgi-bin in your root directory though.
MNS
jasnjohn
09-21-2003, 01:38 AM
Hi, thanks for the tip.
I noticed that's how you call up the counter.pl (for the graphic counter), but the script of Matt's I'm trying to get working is the textcounter, which specifies <!--#exec cgi="cgi-bin/counter.pl"--> as the path to calling the script.
It's just not working though.
Quite frustrating really.
I'm still messing about with it, but if anyone can think of anything obvious I'm missing, let me know.
Thanks,
John
jasnjohn
09-21-2003, 02:11 AM
I can enter the script at the address bar of the browser:
http://www.mydomain.com/cgi-bin/counter.pl
and hey presto! it works.
The counter value is displayed on the screen.
The script prints to screen, the value of the counter.
So, as I understand it, if i were to include the following in an html file, it would be displayed at the appropriate place in my html file:
<!--#exec cgi="http://www.mydomain.com/cgi-bin/counter.pl"-->
Correct?
Unless there's a different way? I just can't imagine what's going wrong.
MotherNatrsSon
09-21-2003, 11:18 AM
Does your server support Server Side Includes?
Calling this program is really very simple. As I have mentioned before, you will need Server Side Includes turned on on your server before you can use this program. Talk to your system administrator or visit my Frequently Asked Questions section for more information on server side includes. If you know they are turned on, or want to try and find out, put the following code into your HTML document:
<!--#exec cgi="/virtual/path/to/counter.pl"-->
So, if I have my counter.pl (or counter.cgi if I have to rename it for my server) program located at http://www.scriptarchive.com/demos/textcounter/counter.pl, then I would put the following into any HTML document I wanted a count to appear in:
<!--#exec cgi="/demos/textcounter/counter.pl"-->
The only other thing I can think of if server side is on at your server is that you have the one part commented out and/or you do not have the chmod permissioons set correctly for one or both of the files. The text file(777) and the .pl file(755).
Have you tried this?
<!--#exec cgi="/cgi-bin/counter.pl"-->
You might also try renaming it to counter.cgi...
MNS
...also, be aware of the fact that the page that you are using the include may have to be renamed with the .shtml extension
...and some hosts/servers don't allow the
<!--#exec cgi="/cgi-bin/counter.pl"--> type command
only this type:
<!--#include virtual="file.htm" -->
which probably does you no good...
so, maybe, if nothing else, call it in an iframe like this:
<iframe name="counter" width="200" height="100" src="/cgi-bin/counter.pl" frameborder="0"></iframe>
jasnjohn
09-22-2003, 07:30 AM
Well CyCo,
you did it.
I changed the extension to .shtml and the counter now works. Why my server people didn't tell me this is necessary is a mystery.
Greatly appreciate your help (and all suggestions from everyone else), I'll sleep well tonight.
Until the next challenge!
Cheers all!
...good deal, I'm glad you got it going...