www.webdeveloper.com
Results 1 to 9 of 9

Thread: Running the CGI script on page load

  1. #1
    Join Date
    May 2006
    Posts
    11

    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

  2. #2
    Join Date
    Jan 2003
    Location
    USA
    Posts
    687
    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.

  3. #3
    Join Date
    May 2006
    Posts
    11
    Thanks

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

  4. #4
    Join Date
    Jan 2003
    Location
    USA
    Posts
    687
    Place the include into the body, where it's output is to be positioned.

  5. #5
    Join Date
    May 2006
    Posts
    11
    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>

  6. #6
    Join Date
    Jan 2003
    Location
    USA
    Posts
    687
    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?

  7. #7
    Join Date
    May 2006
    Posts
    11

    Red face

    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

  8. #8
    Join Date
    Jan 2003
    Location
    USA
    Posts
    687
    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 04:26 PM.

  9. #9
    Join Date
    May 2006
    Posts
    11
    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
  •  
HTML5 Development Center



Recent Articles