http://www.perlmonks.org?node_id=135465

Voytek has asked for the wisdom of the Perl Monks concerning the following question:

Hi! Is it possible to activate a CGI script when the website loads instead of when the user clicks a button? If so, how? Thanks a lot, Voytek

Originally posted as a Categorized Question.

  • Comment on How to load a cgi script when the webpage loads

Replies are listed 'Best First'.
Re: How to load a cgi script when the webpage loads
by jonknee (Monk) on Jan 01, 2002 at 07:26 UTC
    To use server side includes just add this code to your page:
    <!--#exec cgi="/cgi.cgi" -->
    make sure your server can handle them and name your page with the .shtml ending.
Re: How to load a cgi script when the webpage loads
by merlyn (Sage) on Jan 01, 2002 at 05:28 UTC
    Sure. Either make that page a CGI-generated page, or use something like Server-side Includes.
Re: How to load a cgi script when the webpage loads
by zentara (Archbishop) on Jan 02, 2002 at 04:38 UTC
    You could also load a cgi script with the image tag.
    <IMG SRC="cgi-bin/myscript.pl" HEIGHT=0 WIDTH=0 alt="[script]" >
Re: How to load a cgi script when the webpage loads
by LogicalChaos (Beadle) on Jan 03, 2002 at 04:46 UTC
    If you want the cgi script instead of a page (default.html for instance), redirect from your page to your cgi script: <META HTTP-Equiv="Refresh" CONTENT="3; URL=http://your.place.com/cgi/my.cgi">
      Better yet, if you have access to the server (or virtual host) configuration, just disguise your cgi's as .html files by using the AddType and AddHandler under apache or the equivilant on other webservers. Or for a more "friendly" alternative, add .cgi, .pl, .exe or whatever to the DefaultIndex (or equiv. on other servers). -c