Thanks for your follow-up misson!
I tried hitcounter.pl directly from a web browser and it gives me a 500 Error.
The script behind hitcounter.pl uses a variable behind it (either page_name or -summary) so the full command would look like:
hitcounter.pl index, or hitcounter.pl -summary,
or anything of the sort
The script then opens a text file and increases the count of that page, or shows a summary of all the pages
So basically this script has no interaction (at least when the -summary is not requested) with the web browser, it should all happen behind the scenes, which is why I was using the "exec cmd" instead of "exec cgi"
I tried using "include virtual" but I am not sure whether it accepts a variable behind it (i.e. hitcounter.pl -summary)
I am not really including anything into an HTML file. I just want to run a very very simple program behind the scenes to update the page count of all my pages in the same text file and then be able to show a summary of this when requested.
Any further thoughts?
Thanks!
Edit:
Hi Misson!
One question that might (just might) solve my problem...if I use cgi instead of cmd on the exec line (of course praying that cgi is enabled)...
I have the following line in my perl script:
$param=shift @ARGV
which reads in the arguments from the "command line" and stores them in $param
what is the syntax inside the html file if I use cgi? For example...
<!--#exec cgi="cgi-bin/hitcounter.pl -summary"--> or maybe
<!--#exec cmd="cgi-bin/hitcounter.pl?-summary"--> or some other syntax
and also what would the syntax replacing $param=shift @ARGV be inside the perl script to read the parameter behind the "?"
Thank you!
Edit:
OK I think I have figured out how to fix my issue (this thread can be closed now)
I am going to try to explain for completness how I fixed my problem.
I wanted to use a perl script over SSI and not through CGI, so I wanted to use one of the following three ways of executing my script from inside an .html file:
1) <!--#exec cmd="/cgi-bin/hitcounter.pl page_name"-->
2) <!--#exec cgi="/cgi-bin/hitcounter.pl"-->
3) <!--#include virtual="/cgi-bin/hitcounter.pl?param=page_name"-->
1) does not seem to work, probably "IncludesNoExec" is enabled
2) probably works, but it definitely does not work if you want to pass in a paramenter (which I did)
3) works fine, but with some issues which I explain below:
- first, since it is an include, it actually tries to include something into the html file...since I did not want any kind of print to screen, I simply wrote:
Code:
print "Content-type: text/html\r\n\r\n";
and that solved it
- second, for anything of this to work, since it is an SSI, you need to rename your html file to .shtml, another option is to put
AddHandler server-parsed .html
into your .htaccess file
- third, now that you have all this running, you need to put your perl script in the CGI directory (maybe it works from another location, but it definitely works from the cgi-bin directory)
- inside the perl script I needed the following code in order to read the parameters:
Code:
if (length ($ENV{'QUERY_STRING'}) > 0){
$buffer = $ENV{'QUERY_STRING'};
@pairs = split(/&/, $buffer);
foreach $pair (@pairs){
($name, $value) = split(/=/, $pair);
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$in{$name} = $value;
}
}
$param = $in{'param'};
with the above you are ready to go, since you can run the script from any web page, read the parameters into the script, and the script is not upset because you make it print something which ends up not bothering your original page layout.
Thanks Misson for your help!