Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Linking to a CGI from an index.html

Reply
Thread Tools

Linking to a CGI from an index.html

 
 
araminska
Guest
Posts: n/a
 
      12-11-2007
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
 
Reply With Quote
 
 
 
 
dorayme
Guest
Posts: n/a
 
      12-11-2007
In article <(E-Mail Removed)>,
araminska <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
araminska
Guest
Posts: n/a
 
      12-12-2007
..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
 
Reply With Quote
 
Beauregard T. Shagnasty
Guest
Posts: n/a
 
      12-12-2007
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
 
Reply With Quote
 
Chris F.A. Johnson
Guest
Posts: n/a
 
      12-12-2007
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)
 
Reply With Quote
 
Tomasz Chmielewski
Guest
Posts: n/a
 
      12-12-2007
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
 
Reply With Quote
 
Jonathan N. Little
Guest
Posts: n/a
 
      12-12-2007
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
 
Reply With Quote
 
araminska
Guest
Posts: n/a
 
      12-12-2007
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
 
Reply With Quote
 
Jonathan N. Little
Guest
Posts: n/a
 
      12-12-2007
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
 
Reply With Quote
 
DocuMaker
Guest
Posts: n/a
 
      12-14-2007
On Dec 11, 2:58 pm, araminska <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(CGI-Target)Could not connect to CGI-Proxy John Smith Java 0 05-15-2006 09:21 PM
Python-cgi or Perl-cgi script doubt praba kar Python 1 07-30-2005 08:25 AM
Python CGI - Accepting Input, Invoking Another Process, Ending CGI LarsenMTL Python 4 11-04-2004 05:59 PM
Calling cgi from cgi thru 'system' function. Different behaviour on browser v/s cmd line Shailan Perl 2 12-15-2003 04:26 PM
Re: CGI Perl "use CGI" statement fail Jürgen Exner Perl 0 07-31-2003 02:00 PM



Advertisments