LF help Posted February 28, 2012 Posted February 28, 2012 Looking for help with CGI files. I try to include one on my website but it gives an error and sometimes it doesnt show anything. I'am on the Johnny host what i got to do. <!--#include virtual="/cgi-bin/poll.cgi?poll=1" --> actually that is my include for the poll The script contains the following #!usr/bin/perl print "content-type: text/html\n\n" use strict; use CGI qw(:all); my $poll_id = int(param('poll')); my $action; open FH, "poll_${poll_id}_ip.txt"; my $ip = <FH>; close FH; chomp $ip; $ip = defined($ip) ? $ip : ''; if ($ip eq '') { $ip = ':' } my $pat = join('\.', split(/\./, $ENV{'REMOTE_ADDR'})); my $mode = $ip =~ /\:$pat\:/ ? 0 : 1; if (($mode == 0) || defined(param('see'))) { print "Content-Type: text/html\n\n"; print "<center>Poll results</center>\n"; open FH, "poll_${poll_id}_text.txt"; my @lines = <FH>; close FH; print join("<br>", @lines); open FH, "poll_${poll_id}_lines.txt"; my @lines = <FH>; close FH; open FH, "poll_${poll_id}_results.txt"; my @votes = <FH>; close FH; my $sum = 0; foreach (@votes) { $sum += int($_); } print "<center><table border=0 cellspacing=0 cellpadding=4>"; for (my $i = 0; $i <= $#lines; $i++) { my $width = 200; my $a = int($votes[$i] * $width / $sum); my $b = $width - $a; print "<tr><td align=right>$lines[$i] (".int($votes[$i]).")</td><td><table width=$width height=10><tr><td width=$a bgcolor=black></td><td width=$b bgcoloe=blue></td></tr></table></td></tr>"; } print "</table></center>"; } else { if (defined(param('dovote'))) { my $vote = int(param('vote')); open FH, "poll_${poll_id}_lines.txt"; my @lines = <FH>; close FH; if ($vote > $#lines) { print "Content-Type: text/html\n\nError"; exit 0; } open FH, "poll_${poll_id}_results.txt"; my @lines = <FH>; close FH; foreach (@lines) { chomp $_; } $lines[$vote] = int($lines[$vote]) + 1; open FH, ">poll_${poll_id}_results.txt"; print FH join("\n", @lines); close FH; open FH, ">poll_${poll_id}_ip.txt"; print FH "$ip$ENV{'REMOTE_ADDR'}:"; close FH; print redirect(-uri => $ENV{'HTTP_REFERER'}); } else { print "Content-Type: text/html\n\n"; print "<form action=/cgi-bin/poll.cgi method=post>"; print "<input type=hidden name=poll value=$poll_id>"; open FH, "poll_${poll_id}_text.txt"; my @lines = <FH>; close FH; print join("<br>", @lines); print "<center><table border=0 cellspacing=0 cellpadding=4>"; open FH, "poll_${poll_id}_lines.txt"; my @lines = <FH>; close FH; for (my $i = 0; $i <= $#lines; $i++) { print "<tr><td align=center><input type=radio name=vote value=$i></td><td>$lines[$i]</td></tr>"; } print "<tr><td align=center colspan=2><input type=submit name=dovote value=Vote> <input type=submit name=see value=\"See results\"></td></tr>"; print "</table></center>"; print "</form>"; } } my error log says[Tue Feb 28 11:03:07 2012] [error] [client 92.66.136.41] unable to include "cgi-bin/poll.cgi?poll=1" in parsed file /home/jeroenn/public_html/Home.shtmlplease help me on the page it is showing[an error occurred while processing this directive]
bwechner Posted April 25, 2015 Posted April 25, 2015 I have precisely this problem today and no solution so am disappointed to see no replies alas. I cna however help you by observing the content of the script is irrelevant as it isn't even loaded. It is found, but not loaded. I know it's found because if I change the name of the script I get another error in the log saying it's not found. So I firts suspect permissions, and ensured it had 755 and still no luck. So I'm presently bamboozled as SSH is not available to log on and do manual execution diagnositics or poke around. So am relying on some tips here as to what might be at play. My situation is: /public_html/bernd/index.shtmlPerms 0644Complete content:&--#60;META http-equiv="expires" content="0"&--#62;&--#60;!--#include virtual="cgi-bin/build_home.pl"--&--#62; /public_html/bernd/cgi-bin/build_home.plPerms 0755Head:#!/usr/bin/perl####################################################################################### Builds a home page and prints it I would appreciate some insights here. A slight mystery. This is a port form anotehr host where it worked fine, but something is awry here and the include is failing.
bwechner Posted April 29, 2015 Posted April 29, 2015 Bump! Really stuck on this. Any tips appreciated.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now