[ back to toc ]

cgi scripts outside the cgi-bin

Date: 2002/03/03 19:40

I appreciate your making yourself available!
My question is: I just acquired a dedicated server and moved all of my
sites there. I was having trouble with my whois search and my bible
search. These scripts work within their own folders and produce results
from those folders. The techs tell me that no script outside the cgi-bin
will work on these servers. I placed my scripts inside the bin, and one
of them worked, the bible search, however the results are blank. Can you
give me a clue how to make these kinds of scripts work correctly, either
from their folders or from the cgi-bin? or can you guide me to the
correct documentation on this dilemma? I appreciate any help you can give
I could find your whois search page, but not the bible search. However the
issue should essentially be the same.

Your site was on another server where the CGI scripts and the static pages
were in the same directory. This is convenient for most cases but poses
some security risks that I do not have time to detail here. Now your site
is on a server, which is set up different. You have to store all static
HTML and GIF file in some directories and all executable CGI files in
other directories.

This, of course, makes life harder, because you have to more carefully
care the relative URL references and many times you have to maintain the
path to the scripts and from the script output to the static pages.

Summarizing: you have to put the whois.cgi from directory /whois to
/cgi-bin and should alter

$prevpage = "whois.shtml";


$prevpage = "/whois/whois.shtml";

You are a genius! My whois.cgi is running perfect now! Thanks!

The bible.cgi I wrote about doesn't have the $prevpage =
I have two bible scripts. They link to each other. I have spent hours
and hours trying everything I could think of for this new server.... since
the cgi's have to be in the cgi-bin, they are simply not looking in the
directories for data. The most current error is for
http://healinghelp.net/bible2 is:

Can't open /var/www/bible/1.txt: No such file or directory

This is all I have to edit on that one:

# http to your Home page
$home = "http://healinghelp.net/index.html";

# http Path to your cgi directory
$cgi = "http://healinghelp.net/cgi-bin";

# Machine Path to your cgi directory
$cgi_dir = = "/var/www";

# Path to Bible data text files
$text_dir = "$cgi_dir/"."bible";

# Location of the image directory
$images = "../bible2/images";
http://healinghelp.net/bible/ works but comes up with no data or images.
This one uses a search.cgi

Any help you can can give, I will celebrate!

>You are a genius!

Thanks. I am delighted by those words, but rather because it shows me that
I could help. Regarding my knowledge, I would better say that I know my
profession just as you do yours.

Regarding the bible script however I can not really understand all the
details. What I can see however are some things that are suspicious for
me. Your script says:

$cgi_dir = = "/var/www";

which is possible, but is weird. Such a directory is usually a web docs
directory containing static pages. What is more that double = sign is also
something strange. Set

$cgi_dir = "...directory here...";

which is really the cgi directory where the scripts are and

$text_dir = "...text directory here...";

without including the variable $cgi_dir in the string. You do not need
that. I suggest that you go back to the original bible script and try to
configure that. I say this because the format

$text_dir = "$cgi_dir/"."bible";

tells me that this was edited by a person who is not Perl professional.
This line is OK, no problem, but can be written in a simpler and more read
able way:

$text_dir = "$cgi_dir/bible";

putting the variable into the (so called) interpolated string. If it was
edited by you, I apologize it was not ment offending you, just the pure
facts that I diagnose seeing the code fragments to help you as much as I

Also the line

$images = "../bible2/images";

is suspicious for error. In CGI programs generally try to avoid using
relative path to file names. Such a file name is relative to the current
working directory. This is different on different web servers. This may
not be relative to the CGI script itself. Use full path to the images.


[ back to toc ]