Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting Tomcat 6 up to run CGI scripts (Perl)

 
Bob Grossman
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are trying to enable our Tomcat 6 server to run a CGI script in Perl. We went to tomcat6/conf/web.xml and uncommented the portions of XML that defined the CGI servlet, setting cgiPathPrefix to WEB-INF/cgi, and its mapping, setting the URL pattern to cgi/* . We created a WEB-INF/cgi directory and unpacked scripts into it. We downloaded servlets-cgi.renametojar from a Tomcat 5 distribution, placed it in tomcat6/lib/, and renamed it to servlets-cgi.jar. (There was no such file in the Tomcat 6 distribution.) We restarted Tomcat after each step and pointed our browser to the CGI script URL. The browser loads the script as text, but does not run it. The text tells us that we haven't configured Tomcat properly to run CGI scripts. The first line in the CGI script is

#!/usr/bin/perl

and we have confirmed that we have a working Perl installation at that location.

Any suggestions?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it a privileged context?

Also, I'm not sure about the bang-script notation, as per http://tomcat.apache.org/tomcat-6.0-doc/cgi-howto.html

It wasn't obvious to me that it'd be honored.
 
Bob Grossman
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In /etc/tomcat6/context.xml, I see the line,

<Context privileged="true">

So I believe the answer to your question is, yes.
 
Charles Owen
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are running Tomcat6 then you do not need to add this cgi jar. That's only if you are using Tomcat 5.5 or below.

I don't think your problem is in the perl installation. I think it's how you are configuring the CGI.
I've gotten CGI to work in Tomcat6. However, in my case I am turning on the CGI within my application web.xml, rather than in the global web.xml.

This is my directory structure.
/webapps/perlexample/WEB-INF/cgi/test.pl

Then I created a perlexample.xml in my $CATALINA_BASE/conf/Catalina/localhost directory.



Then it works. I am thinking you are missing this application xml in your $CATALINA_BASE/conf/Catalina/localhost directory.
 
Charles Owen
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And this is my very simple PERL script.

 
Jitmer Jijo
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you are getting java.security.xception make sure to do the following

In the directory $CATALINA_HOME\conf\ set the root element as <Context privileged="true"> in the context.xml file

i.e add privileged="true" attribute in the <Context > root element
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic