We help IT Professionals succeed at work.

simple CGI: addresses index

menorcanet asked
I have no idea on CGI.. but I know I can use it in my site.

I want to have a html page with many links, like:


and when clicking on them for site1 go to http://www.whatever

but I want to have these links in another place in my
site, and access them by a CGI, something like

Can someone do it for me or tell where to download one
and how to install it ?

Watch Question

try this :-

#!/usr/bin/perl -w

use CGI qw(param);

@urls = ('http://www.site1.com/', 'http://www.site2.com/', 'http://www.site3.com/');

$location = $urls[param('siteindex')];

if ($location)
    print("Location: $location\n\n\n");
    print("Content-type: text/plain\n\nUnknown site index.");


thanks, I've just tried it, but I get this error msg:

CGIWrap Error: Script Execution Failed
CGIWrap encountered an error while attempting to execute this script:

Error Message: Permission denied
Error Number: 13
This message usually indicates there is a problem with the script itself. Often this indicates either that the #! line of the script is incorrect, or the script was uploaded in binary mode instead of ascii mode. Check to make sure that the script does not have control-M's at the end of every line. That will prevent it from executing. An easy fix that takes care of this most of the time is to put '#!/.../perl --' instead of '#!/.../perl' on the first line of the script.
If you are not the owner of this script, please forward this error and the URL that caused it to the script owner. That is often the component in the URL right after /cgiwrap/.

strange ... this works on my box ...

which OS is the server using ?? Do you know the perl path of the server ?

If you know, please change #! line to the path of the perl, for example, if you are using windows, and Perl is in C:\perl\bin\perl.exe, try use the following line instead.

#!C:/perl/bin/perl.exe -w


the server is a cobalt in UNIX, and there is no cgi-bin
directory, I dropped the cgi file to the web root.
ar ... here is a check list for you :
1. have u chmoded the file to make it executable ? (755 is the for-all workable permission)
2. are you uploading it in ascii ?
3. is the perl path correct ?
4. did server allows you to run cgi ?


oups, I set the file permission to 755, and it's working now =) thanks a lot.


one more q. is it possible to deny access (not load
the page) if the request comes from outside our site ?

how ?
is the server apache ?
wait ... you want to deny access of the cgi ONLY or ordinary files ??


yes it's apache.

our site is http://www.menorca.net (or menorca.net)

if someone uses the CGI from http://whatever.com/pahe.htm
in stead of http://menorca.net/page.htm

then the CGI won't load the requested site.

that's what I need.

is it possible ?


hello ?


hello ?

Explore More ContentExplore courses, solutions, and other research materials related to this topic.