Linking to a CGI from an index.html

Discussion in 'HTML' started by araminska, Dec 11, 2007.

  1. araminska

    araminska Guest

    I have never done any HTML except for trivial static pages, so I hope I
    can ask this question in a way that can be understood.

    When a person surfs to somepage.com, the remote server automatically
    starts the script index.html. But if the site is composed of entirely
    CGI scripts, then you need to actually run the script at
    somepage.com/cgi-bin/somescript.pl (or whatever). Just surfing to
    somepage.com won't find it.

    The question. How do you redirect or repoint from the default
    static index.html to the starting cgi-script without the surfer having
    to click on a link (or even knowing that an index.html exists?

    Thanks anyone. If the above still doesn't make sense, I will try again.

    Araminska
     
    araminska, Dec 11, 2007
    #1
    1. Advertising

  2. araminska

    dorayme Guest

    In article <>,
    araminska <> wrote:

    > I have never done any HTML except for trivial static pages, so I hope I
    > can ask this question in a way that can be understood.
    >
    > When a person surfs to somepage.com, the remote server automatically
    > starts the script index.html.


    It is not a script. As a whole, it is a text file. Inside the
    text might be special text like e.g. php includes which, given
    the right server configuration (basically the server is set to
    look out for php code within the html doc), will get the php
    engine that is on the server to parse the bits and do things like
    gather text from some folder (an "includes" folder) and serve it
    up to the end user along with all else the html mark up dictates.

    You can have much of the html file full of includes and scripts
    and little actual "ordinary" text and markup in the file. But the
    end user still simply requests the html file. In it should be
    contained all the correct code and/or paths to code for the
    server to fetch and send something useful to the end users
    browser.


    > But if the site is composed of entirely
    > CGI scripts, then you need to actually run the script at
    > somepage.com/cgi-bin/somescript.pl (or whatever). Just surfing to
    > somepage.com won't find it.
    >
    > The question. How do you redirect or repoint from the default
    > static index.html to the starting cgi-script without the surfer having
    > to click on a link (or even knowing that an index.html exists?
    >
    > Thanks anyone. If the above still doesn't make sense, I will try again.
    >


    A

    --
    dorayme
     
    dorayme, Dec 11, 2007
    #2
    1. Advertising

  3. araminska

    araminska Guest

    ..html.
    >
    > It is not a script. As a whole, it is a text file. Inside the
    > text might be special text like e.g. php includes which, given
    > the right server configuration (basically the server is set to
    > look out for php code within the html doc), will get the php


    In my case, it is a perl script(s) that is used. The administrator doesn't
    allow php on the company servers and besides that, I don't know php.

    But my scripts have to be in /usr/lib/cgi-bin (well, they don't, but that
    is the usual place) and I can call an HTML text file from a script but
    can't figure how to call a script from a static HTML page without clicking
    on a link. Maybe that is why they call them static.

    But I know there are lots of web sites that are composed entirely of perl
    (or ruby or whatever) scripts and all HTML there is generated on the fly.
    But how does the first script on a site get called by default?

    Probably I am looking at it from the wrong place. It may be an Apache
    issue where the web server transfers the incoming surfer to the proper
    startup script. Will have to ask my web server admin next week.

    Thanks
    Araminska
     
    araminska, Dec 12, 2007
    #3
  4. araminska wrote:

    > In my case, it is a perl script(s) that is used. The administrator
    > doesn't allow php on the company servers and besides that, I don't
    > know php.
    >
    > But my scripts have to be in /usr/lib/cgi-bin (well, they don't, but
    > that is the usual place) and I can call an HTML text file from a
    > script but can't figure how to call a script from a static HTML page
    > without clicking on a link. Maybe that is why they call them static.


    Put a php page in the root, named index.php, comprised of only:

    <?php
    header( "Location: usr/lib/cgi-bin/somescript.pl" )
    ?>

    Remove any index.html files.

    --
    -bts
    -Motorcycles defy gravity; cars just suck
     
    Beauregard T. Shagnasty, Dec 12, 2007
    #4
  5. On 2007-12-11, araminska wrote:
    > I have never done any HTML except for trivial static pages, so I hope I
    > can ask this question in a way that can be understood.
    >
    > When a person surfs to somepage.com, the remote server automatically
    > starts the script index.html.


    That is not a script; index.html is an HTML page.

    And the file needn't, in most server configurations, be index.html.

    > But if the site is composed of entirely CGI scripts, then you need
    > to actually run the script at somepage.com/cgi-bin/somescript.pl (or
    > whatever). Just surfing to somepage.com won't find it.


    If you put your script at somepage.com/index.cgi and remove
    index.html, that script will (again, on most servers) be executed.

    > The question. How do you redirect or repoint from the default
    > static index.html to the starting cgi-script without the surfer having
    > to click on a link (or even knowing that an index.html exists?


    You can also use a server-side include to run the script, e.g. in
    index.html, put:

    <!--#include virtual="cgi-bin/somescript.pl" -->

    --
    Chris F.A. Johnson, webmaster <http://Woodbine-Gerrard.com>
    ===================================================================
    Author:
    Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
     
    Chris F.A. Johnson, Dec 12, 2007
    #5
  6. Beauregard T. Shagnasty schrieb:
    > araminska wrote:
    >
    >> In my case, it is a perl script(s) that is used. The administrator
    >> doesn't allow php on the company servers and besides that, I don't
    >> know php.
    >>
    >> But my scripts have to be in /usr/lib/cgi-bin (well, they don't, but
    >> that is the usual place) and I can call an HTML text file from a
    >> script but can't figure how to call a script from a static HTML page
    >> without clicking on a link. Maybe that is why they call them static.

    >
    > Put a php page in the root, named index.php, comprised of only:
    >
    > <?php
    > header( "Location: usr/lib/cgi-bin/somescript.pl" )
    > ?>
    >
    > Remove any index.html files.


    The administrator doesn't allow php, so here is a html alternative:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
    <HTML>
    <HEAD>
    <TITLE></TITLE>
    <META http-equiv=Refresh Content="0; Url=cgi-bin/blah.pl">
    </HEAD>
    </HTML>


    And the best option would be to configure the web server correctly - if
    it's Apache, look at DirectoryIndex directive, i.e.:

    DirectoryIndex index.cgi

    This can be set up either in server or virtual host configuration
    (requires root privileges), but I think also in .htaccess file when you
    have no root privileges, and the main configuration allows you to
    override DirectoryIndex.


    --
    Tomasz Chmielewski
    http://wpkg.org
     
    Tomasz Chmielewski, Dec 12, 2007
    #6
  7. Tomasz Chmielewski wrote:
    > Beauregard T. Shagnasty schrieb:
    >> araminska wrote:
    >>
    >>> In my case, it is a perl script(s) that is used. The administrator
    >>> doesn't allow php on the company servers and besides that, I don't
    >>> know php.
    >>> But my scripts have to be in /usr/lib/cgi-bin (well, they don't, but
    >>> that is the usual place) and I can call an HTML text file from a
    >>> script but can't figure how to call a script from a static HTML page
    >>> without clicking on a link. Maybe that is why they call them static.

    >>
    >> Put a php page in the root, named index.php, comprised of only:
    >>
    >> <?php
    >> header( "Location: usr/lib/cgi-bin/somescript.pl" )
    >> ?>
    >>
    >> Remove any index.html files.

    >
    > The administrator doesn't allow php, so here is a html alternative:
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">


    Why and ancient doctype?

    > <HTML>
    > <HEAD>
    > <TITLE></TITLE>
    > <META http-equiv=Refresh Content="0; Url=cgi-bin/blah.pl">
    > </HEAD>
    > </HTML>


    No don't do it with a meta refresh
    >
    > And the best option would be to configure the web server correctly - if
    > it's Apache, look at DirectoryIndex directive, i.e.:
    >
    > DirectoryIndex index.cgi
    >
    > This can be set up either in server or virtual host configuration
    > (requires root privileges),


    Doubt any commercial hosting company will allow him root access. And any
    way this will not solve his problem, his problem is the script is not in
    his document root.

    > but I think also in .htaccess file when you
    > have no root privileges, and the main configuration allows you to
    > override DirectoryIndex.


    the .htacess is really the only and best way to go the way to go.

    RewriteEngine On
    RewriteRule ^index\.html$ cgi-bin\/somescript.pl [L]
    RewriteRule ^$ cgi-bin\/somescript.pl [L]

    This way

    http://www.example.com
    or
    http://www.example.com/index.html

    will be redirected to 'somescript.pl', the browser will still show the
    former url, so 'somescript.pl' will look like 'index.html' in the
    document root.

    Also any other pages on his site will not be affected, i.e.,

    'http://www.example.com/somepage.html' will still go to 'somepage.html'

    and

    'http://www.example.com/somedir/somepage.html'

    will still go to 'somedir/somepage.html'

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Dec 12, 2007
    #7
  8. araminska

    araminska Guest

    It is probably pretty obvious by now that I know very little about 'Net
    programming or web servers, since my programming has been strictly
    confined to industrial machine control with C and Perl. 'Net coding is a
    whole lot different from having total root control of a development
    machine like I am used to.

    Anyway, thanks for all of the above. They will probably all work - I just
    need to try them and see which one fits my needs.

    By the way, after asking I was told that the IT department doesn't outlaw
    PHP, after all. Just PHP programs written by inexperienced 'Net newbies.
    (I wonder who they were thinking of?)

    Thanks all
    Araminska
     
    araminska, Dec 12, 2007
    #8
  9. araminska wrote:
    > It is probably pretty obvious by now that I know very little about 'Net
    > programming or web servers, since my programming has been strictly
    > confined to industrial machine control with C and Perl. 'Net coding is a
    > whole lot different from having total root control of a development
    > machine like I am used to.
    >
    > Anyway, thanks for all of the above. They will probably all work - I just
    > need to try them and see which one fits my needs.
    >
    > By the way, after asking I was told that the IT department doesn't outlaw
    > PHP, after all. Just PHP programs written by inexperienced 'Net newbies.
    > (I wonder who they were thinking of?)


    If it is just the index page that you want to change the .htacess file
    the simplest and most effective way to go.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Dec 12, 2007
    #9
  10. araminska

    DocuMaker Guest

    On Dec 11, 2:58 pm, araminska <> wrote:
    > I have never done any HTML except for trivial static pages, so I hope I
    > can ask this question in a way that can be understood.
    >
    > When a person surfs to somepage.com, the remote server automatically
    > starts the script index.html. But if the site is composed of entirely
    > CGI scripts, then you need to actually run the script at
    > somepage.com/cgi-bin/somescript.pl (or whatever). Just surfing to
    > somepage.com won't find it.
    >
    > The question. How do you redirect or repoint from the default
    > static index.html to the starting cgi-script without the surfer having
    > to click on a link (or even knowing that an index.html exists?
    >
    > Thanks anyone. If the above still doesn't make sense, I will try again.
    >
    > Araminska


    <script>
    document.location="http://www.mywebsite.com/path-to-my-cgi-script.pl"
    </script>

    ---
    http://www.outsource2documaker.com
    Managing outsourced projects ranging from fine artwork and business
    graphics to website design and maintenance.
     
    DocuMaker, Dec 14, 2007
    #10
  11. DocuMaker wrote:

    > <script>


    <script type="text/javascript">

    > document.location="http://www.mywebsite.com/path-to-my-cgi-script.pl"
    > </script>
    >


    And what happens when the user does not have javascript enabled, eh?

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Dec 14, 2007
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. karthikeyavenkat
    Replies:
    2
    Views:
    603
    Bryce
    Mar 17, 2005
  2. Josef 'Jupp' Schugt

    (Ab)using class CGI as non-CGI HTML generator?

    Josef 'Jupp' Schugt, Mar 5, 2005, in forum: Ruby
    Replies:
    3
    Views:
    257
    Lee Braiden
    Mar 6, 2005
  3. Shawn W_
    Replies:
    5
    Views:
    288
    Aldric Giacomoni
    Sep 16, 2009
  4. Nikos
    Replies:
    4
    Views:
    176
    Nikos
    Apr 26, 2005
  5. Tomasz Chmielewski

    sorting index-15, index-9, index-110 "the human way"?

    Tomasz Chmielewski, Mar 4, 2008, in forum: Perl Misc
    Replies:
    4
    Views:
    307
    Tomasz Chmielewski
    Mar 4, 2008
Loading...

Share This Page