Debugging CGI and path

cosmoc wrote on Fri Aug 25 16:08:49 MEST 2006:
I have been attempting to debug a CGI application but all of my Java Script,
Style sheet and image files are getting "/cgi-bin/" pre-appended to their
file names.   

My directory structure is
          :              :
       cgi-bin         htdocs
                   :           :
               templates       images

All .pl and .cgi perl files are in cgi-bin
All  .html and .js and .css are in htdocs 
All Template-Toolkit files are in htdocs/templates
All .gif   .png  are in htdocs/images

I have the following set in my run configuration

HTML Root Directory:   c:\workspace\toplev\htdocs
HTML Startup File:     c:\workspace\toplev\htdocs\index.html
CGI Root Directory:  c:\workspace\toplev

The file extension for CGI list includes ".pl, .cgi"

Since "/cgi-bin/" is pre-appended to all files, I had to leave the CGI Root
Directory to be toplev to get my perl scripts to run, however, I have not
succeeded in getting many of the image, css, or js files.  Looking at the
Web console log, I see "/cgi-bin/" somehow appearing in the file name.

For instance, the log will show
file.: Looking for file: (C:/workspace/toplev/htdocs) (\cgi-bin\abc.js)

From that I am thinking that the actual filename, abc.js, has somehow been
concatenated with \cgi-bin\    however, I do not see where that would be
taking place in the code.

In fact, what if the cgi directory was not called cgi-bin?   Where is this
string set?

Thank you
jploski wrote on Fri Aug 25 16:36:57 MEST 2006:
Have you tried setting both HTML Root Directory and CGI Root Directory to
cosmoc wrote on Fri Aug 25 16:39:15 MEST 2006:
Yes I have -   "/cgi-bin/" still is prefixed to .css, .js, and .gif files
jploski wrote on Fri Aug 25 16:55:27 MEST 2006:
What sort of URLs do your CGI scripts output in HTML in order to refer to
the images? Relative URLs? For example,

produced by a CGI script under /cgi-bin/ would rightfully be interpreted
by the client as a request for /cgi-bin/foo.gif (unless a 
element is also present. Is this what you are describing?
cosmoc wrote on Fri Aug 25 17:14:06 MEST 2006:
Yes -  I think that may be it.

For instance, the index.html has a line with

Then within will have a function to load a template file, such
as mytemplate.tmpl

This Template-Toolkit file will then include html for loading js and image
and css files

The links in the template file use a template variable for the path - for
href="[% app.docroot %]mystyle.css"

I have examined app.docroot and it is empty for this configuration, therefore
the link is relative - which then probably explains the /cgi-bin/ prefix.

This problem is not a debugger problem, but more likely a configuration
issue somewhere in this code I am testing.  app.docroot should contain an
absolute path to the html directoy for the installation directory to avoid
the problem I am seeing, if I understand this correctly.    I will examine
the source of app.docroot in this code set and test again if I can fill
that variable with the path to my directory.

Thank you
cosmoc wrote on Fri Aug 25 17:51:56 MEST 2006:
Yes - I found the issue and it was with the configuration of this installation.
 Once I provided the the variable that is read in and eventually propagated
to the template variable, app.docroot, the paths no longer were relative
and the mysterious /cgi-bin/ disappeared.

Thank you for the reply. Your comment was very helpful.

Note: The above is an archived snapshot of a forum thread. Use the original thread at to post comments.