Running the CGI script on page load
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
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.
Code:
<!--#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.
Thanks
Does this code go in the HEAD or BODY of the main HTML file?
Place the include into the body, where it's output is to be positioned.
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>
First of all, the include should be like this:
Code:
<!--#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?
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
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).
Last edited by CyCo; 05-29-2006 at 03:26 PM .
Thanks.
The server wasn't set up to run the scripts.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks