PDA

View Full Version : CGI Server Side Include Not Working


whataslacker
7-10-06, 02:47 PM
I have a banner rotator on my site and the old site worked fine...new no longer works need help!

The include line was...
<!--#exec cgi="/banners/ad.pl"-->

And my site had to have shtml fo rthe includes to work in the past I assume that is the same but since SO much is not let me know if it can go back to htm or html which I prefer.

Any ideas how to get the above include statement to work again on my thousand plus pages????

smcone
7-11-06, 02:05 AM
The include line was...
<!--#exec cgi="/banners/ad.pl"-->
************************************************** **************************
The new Endurance servers DO NOT support
that command nor do CGI calls work on index pages
named index.xxx, the CGI will only work on pages named
something OTHER than index.shtm, or index.htm, or
index.html.

This problem has been around now for about 2 weeks.

You have to use instead of exec calls:

<!--#include virtual="/cgi-bin/ad.pl"-->

if you takes a look at the forum section: PERL,
you will find many posts along with workarounds for the problem.

Steve
Steven Carlozzi-Owner
SMC Electronics
www>smcelectronics>com

Sparhawk
8-7-06, 03:28 PM
My site includes several server-side includes. All I get is " [an error occurred while processing this directive]" instead of the script return code.

It has been this way since the migration.

NeilFawcett
8-8-06, 06:14 PM
The include line was...
<!--#exec cgi="/banners/ad.pl"-->
************************************************** **************************
The new Endurance servers DO NOT support
that command nor do CGI calls work on index pages
named index.xxx, the CGI will only work on pages named
something OTHER than index.shtm, or index.htm, or
index.html.

This problem has been around now for about 2 weeks.

You have to use instead of exec calls:

<!--#include virtual="/cgi-bin/ad.pl"-->

if you takes a look at the forum section: PERL,
you will find many posts along with workarounds for the problem.

I think that may be a little mis-leading... And also incorrect!?

I think the migration script does a straight forward replace of the SSI from exec to virtual... No change of directory is required.

So theoretically:-
<!--#exec cgi="/banners/ad.pl"-->
could go to:-
<!--#include virtual="/banners/ad.pl"-->

The kiosk listed all my SSI conversions, and after migration I simply FTP'd the converted HTML files from the server back to my machine...


Also regarding the name of the HTML file doing the include virtual, all my html pages are .html, and I have ones call index.html doing it...



SPARHAWK -- Can you give an example of one of your current SSI's that is not working? Can you also try changing it to the "include virtual" method shown above to see if that resolves it?

Sparhawk
8-9-06, 02:07 AM
SPARHAWK -- Can you give an example of one of your current SSI's that is not working? Can you also try changing it to the "include virtual" method shown above to see if that resolves it?

I am already using the "include virtual" method right on my front page at http://www.sparhawks.com/
<!--#include virtual='scripts/general/qotd.cgi' -->
This returns:
[an error occurred while processing this directive]

snowmaker
8-9-06, 02:21 AM
Sparhawk: just a shot in the dark, but try /scripts/general/qotd.cgi in place of scripts/general/qotd.cgi

BTW, I edited your post above so the URL works (I removed a : from the end)

Sparhawk
8-9-06, 02:27 AM
Sparhawk: just a shot in the dark, but try /scripts/general/qotd.cgi in place of scripts/general/qotd.cgi

Good thought, but not luck. Still broken. I even tried changing the filename from index.html to index.shtml, still no luck.

cc1030
8-9-06, 02:30 AM
Just a shot in the dark here, but does your .cgi program output the appropriate header? I believe all .cgi programs called from a virtual include must include the Content-Type header (so the output from the cgi program would be the following:


Content-Type: text/plain

This is the text that will appear. The "Content-Type" header and the blank line after it will not appear in the web page that called this script.

Sparhawk
8-9-06, 02:41 AM
Just a shot in the dark here, but does your .cgi program output the appropriate header? I believe all .cgi programs called from a virtual include must include the Content-Type header (so the output from the cgi program would be the following:

Another valid point, but not the problem at hand.
Here is my script:
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);

open( FILEHANDLE, "qotd.txt" );
@quotes = <FILEHANDLE>;
close( FILEHANDLE );

$index = rand @quotes;
$qotd = $quotes[$index];

print "Content-Type: text/html\n\n";
print "$qotd";


And, if you run the script through a browser, it outputs correctly.
http://www.sparhawks.com/scripts/general/qotd.cgi

cc1030
8-9-06, 02:53 AM
Does your cgi script have the proper permissions (755)? I think .cgi files called directly don't need the execute permissions, but .cgi files called from an SSI do need them. If the permissions are correct, and it still doesn't work, then please post the relevant portion of your home page code, and I'll try it out on my site.

Sparhawk
8-9-06, 03:04 AM
Does your cgi script have the proper permissions (755)? I think .cgi files called directly don't need the execute permissions, but .cgi files called from an SSI do need them. If the permissions are correct, and it still doesn't work, then please post the relevant portion of your home page code, and I'll try it out on my site.

Oops. I had the permissions as 755 on the old site, but somehow they are at 644 on the new site. Even after fixing that issue, though, I still have the same issue.

I already included the exact include code above.

NeilFawcett
8-9-06, 03:25 AM
Can i suggest then you knock up a very simple test.html page with this include virtual on it. And then raise a support ticket showing if you run the script directly it works, but with SSI it, you get your error.

HAve you got SSI working anywhere else on your site?

Also, the migration script added a line to my .htaccess... Not sure if this is anything to do with it:-
AddType text/x-server-parsed-html .html

I suspect not as your error implies it's trying to do the SSI, but failing to run it!?!

Sparhawk
8-9-06, 03:39 AM
Can i suggest then you knock up a very simple test.html page with this include virtual on it. And then raise a support ticket showing if you run the script directly it works, but with SSI it, you get your error.

HAve you got SSI working anywhere else on your site?

Also, the migration script added a line to my .htaccess... Not sure if this is anything to do with it:-
AddType text/x-server-parsed-html .html

I suspect not as your error implies it's trying to do the SSI, but failing to run it!?!

That line is already in my .htaccess file. No pages on my site have functioning SSI. All SSI references return the same error message.

cc1030
8-9-06, 06:39 AM
I've got in working on my site, so I'm not sure what the problem is. Here are my setup:

Directory: /ssi
Permissions: 755

File: /ssi/.htaccess
Permissions: 644
AddType text/x-server-parsed-html .html

File: /ssi/index.html
Permissions: 644
<html><body>
<!--#include virtual='scripts/general/qotd.cgi' -->
</body></html>

Directory: /ssi/scripts
Permissions: 755

Directory: /ssi/scripts/general
Permissions: 755

File: /ssi/scripts/general/qotd.cgi
Permissions: 644
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);

open( FILEHANDLE, "qotd.txt" );
@quotes = <FILEHANDLE>;
close( FILEHANDLE );

$index = rand @quotes;
$qotd = $quotes[$index];

print "Content-Type: text/html\n\n";
print "$qotd";

File: /ssi/scripts/general/qotd.txt
Permissions: 644
First -- 1st
Second -- 2nd
Third -- 3rd
Fourth -- 4th
Fifth -- 5th
Sixth -- 6th
Seventh -- 7th
Eighth -- 8th
Ninth -- 9th
Tenth -- 10th

cc1030
8-9-06, 06:48 AM
Have you tried a very simple file like the following?

date.html:
<html><body>
Today is <!--#echo var="DATE_LOCAL" -->
</body></html>

NeilFawcett
8-9-06, 09:20 AM
Surely had to be the permission on the script, or the directory it was in then? Maybe you can have permissions that allow the script to be called directly from the web, but don't allow it to be SSI?