Linking to a CGI from an index.html

A

araminska

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
 
D

dorayme

araminska said:
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
 
A

araminska

..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
 
B

Beauregard T. Shagnasty

araminska said:
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.
 
C

Chris F.A. Johnson

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" -->
 
T

Tomasz Chmielewski

Beauregard said:
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.
 
J

Jonathan N. Little

Tomasz said:
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'
 
A

araminska

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
 
J

Jonathan N. Little

araminska said:
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.
 
D

DocuMaker

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top