Click to See Complete Forum and Search --> : Running the CGI script on page load


lochindaal
05-29-2006, 08:06 AM
I have a Perl script that reads a txt database and outputs a table.

How do I get the script to run automatically when a user arrives at my site without them clicking a link.

i.e. they go to www.myhomepage.com

myhomepage.com loads up and displays the perl generated table on the fly

CyCo
05-29-2006, 12:25 PM
Although there are many possible techniques available that will allow one to ascertain the required results, probably the easiest method would be to use SSI.<!--#include virtual="/cgi-bin/myscript.pl"-->Alternative techniques could also include the use of frames or iframes, modules such as HTML::Template, HTML::Mason, or other variations on these themes.

lochindaal
05-29-2006, 02:24 PM
Thanks

Does this code go in the HEAD or BODY of the main HTML file?

CyCo
05-29-2006, 02:37 PM
Place the include into the body, where it's output is to be positioned.

lochindaal
05-29-2006, 02:47 PM
I've made a simple test HTML file (code below) but when I run it nothing happens

<HTML>
<HEAD>
<META NAME="Generator" CONTENT="Cool Page version 2.7 Pro, Aug 11 2001 for Windows">
<BASE TARGET="_top">
<STYLE TYPE="text/css">BODY {margin-left:0; margin-right:0; margin-top:0;}</STYLE>

</HEAD>

<BODY SCROLL="auto" BGCOLOR="#FFFFFF" TOPMARGIN=0 LEFTMARGIN=0>

<DIV ID="idElement29" style="position:absolute; top:39px; left:29px; width:224px; height:140px;">
<!--#include virtual="http://localhost/cgi-bin/news_output.pl"-->
</DIV>
</BODY>
</HTML>

CyCo
05-29-2006, 03:07 PM
First of all, the include should be like this:<!--#include virtual="/cgi-bin/news_output.pl"-->And secondly, the test page should be saved with an extension of .shtml
It appears that you are testing this locally. Have you enabled SSI in your server config?

lochindaal
05-29-2006, 03:54 PM
I don't think SSI can be enabled.

I put the files on line and renamed the test file to .shtml

Now when I run the test file it prints all the code for the .pl file on the screen and creates the table with a $variable inside it.

Do I need to change the set up of the .pl file?

Sorry I thought this was going to be simple when I started

CyCo
05-29-2006, 04:04 PM
OK...let's back up just a bit. Your script runs as desired by itself, correct?

UPDATE:
Sounds like you need to chmod the script to 0755 (755).

lochindaal
06-19-2006, 04:47 PM
Thanks.

The server wasn't set up to run the scripts.