• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

setting Tomcat 6 up to run CGI scripts (Perl)

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And this is my very simple PERL script.

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Where does a nanny get ground to air missles? Protect this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic