PDA

View Full Version : How can I embed a .cgi file into an .htm file at bluehost?


Shag
01-02-2008, 08:11 PM
I am in the process of moving a site over to bluehost, and have run into some problems. I'm hoping some of the experts here can help me out...

1. It appears that bluehost does not allow execution of .cgi scripts outside of the cgi-bin directory. Is that true?

2. I'm having trouble embedding a .cgi file into my .htm file. On my other host, I use a php include without issue: <? include("/cgi-bin/script.cgi"); ?>. Unfortunately, this does not work at bluehost - I get a php error on this line. It appears that the .cgi script is being interpreted as a php page, rather than a perl script, despite the perl declaration in the .cgi file.

I use this include method for a number of other .htm files, and it works fine - it only seems to fail when I attempt to include a .cgi file. I don't want to change my pages to .shtml for SSI, and I don't believe I can add .htm files to the SSI-interpreted files, as I have them designated to use php for these includes.

Anybody have any suggestions? Any idea why this would work on one host but not bluehost?

Basil
01-02-2008, 08:17 PM
Does the CGI script work correctly accessing it directly?

Shag
01-02-2008, 08:53 PM
Does the CGI script work correctly accessing it directly?

Yes, the cgi script works fine on its own. It's only when it's within a php include that the error occurs. I get the exact same error if I run "php script.cgi" at the command line, which is what led me to believe that the script was being interpreted by php, rather than perl...

Basil
01-02-2008, 10:15 PM
In my brief test it appears to be reading the contents of the cgi file as text, rather than executing it.

I can't really recommend including a cgi script in a php file in the first place though.

Maybe somebody else has a solution for this.

siguie
01-03-2008, 02:28 AM
You should be able to use ssi to execute perl scripts within an html file (shtml), usually it's the "exec" or "include" command but I think you have to add another apache handler here at bluehost. I forget exactly what exactly the process was but it is possible to do it. I hope that helps a little :)

arul
01-05-2008, 04:01 PM
You should be able to use ssi to execute perl scripts within an html file (shtml), usually it's the "exec" or "include" command but I think you have to add another apache handler here at bluehost. I forget exactly what exactly the process was but it is possible to do it. I hope that helps a little :)

Yes, the entry in .htaccess is:

AddType text/html .html
AddHandler server-parsed .html

And the HTML file should have something like this:

<!--#exec cmd="date.pl"-->

I have a small tutorial here (http://aruljohn.com/info/ssi/) .

There's a little SSI demo here (http://aruljohn.com/demo/ssi.html).