Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to put syntax-highlighted source code (C) on a website using CGI. I have the GNU source-highlight package on the web-server. Can anyone tell me how to link the source-highlight-cgi script (shell script, not perl) into CGI.

I guess I need a perl script in the cgi-bin to point somehow at the source-highlight-cgi shell script I but have no experience of doing this.

Note: CGI is enabled and working on the server.

share|improve this question
You just have to put that script into the cgi-bin directory and make it executable. What I can't tell you is how you specify the source file that needs highlighting via the URL. You may need to dive into the source to work out how do that. – paulmorriss Jan 30 '12 at 16:57
There is a comment in the script (bourn shell, not perl) saying "This wrapper script should never be moved out of the build directory. If it is, it will not operate correctly.", so I need to call it from cgi-bin – William Morris Jan 30 '12 at 19:04

Does this help?

Running scripts outside of the cgi-bin


This article describes how to execute scripts outside of your cgi-bin using a .htaccess file.

You will be able to execute CGI scripts outside of your cgi-bin. Enabling this in a web-accessible directory is slightly more insecure than limiting script execution to the cgi-bin, because if a malicious script is ever uploaded to your server, it will be more easily able to be executed.


Before you start, you'll need:

  • FTP login credentials and a plain text editor or SSH enabled and vi knowledge.


Add the following lines to your .htaccess file:

Filename: .htaccess

AddHandler cgi-script .cgi .pl

Options +ExecCGI

Then, upload the .htaccess file to the directory in which you want to enable CGI script execution, via FTP. For more information on creating and uploading .htaccess files, please see: Using .htaccess files.


You can add any file extension to the AddHandler line in your .htaccess file. The example is for CGI and Perl scripts.

If you are using this directive in your existing cgi-bin directory, the above line alone will also work.

Source: Running scripts outside of the cgi-bin

share|improve this answer
Thanks, it probably does. I've actually forgotten why I wanted to do that now, but if I ever need to in future, I'll know where to look :-) – William Morris Jan 11 '15 at 1:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.