tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: Calling a CGI script from Servlet
Date Sun, 01 Aug 2010 12:19:02 GMT


Thanks for the reply. I am using Tomcat 6.0.20.  The script is located in WEB-INF/cgi and
in the call I am using an absolute path:

//System Call
String[cmd] = {"python", 'home/troy/NetBeansProjects/GSMFilter/web/WEB-INF/cgi/",
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(cmd);
int exitVal = proc.waitFor();

//Write exit value to file - Get value of zero
toFile.write("" + exitVal);


I am new to configuring tomcat (I have run it for a few years as it is packaged with Netbeans)
and new to linux and I am stuck on a particular problem.

I have a project in which I am trying to call a python code from a servlet.  I am using tomcat6
on Ubuntu 10.04.  I have used both Runtime.exec() as well as ProcessBuilder to make the call.
 I have completely copied the code from the JavaWorld article When Runtime.exec() won't (
; I have granted full permissions on all the files (read, write and execute).  When I get
an exit value on the execution of the script I get a value of 0 (zero).  I am able to execute
the script from a simple java program in this environment (tomcat and Ubuntu) using the same
syntax but not in the servlet.  I am able to execute the script from the servlet in Ubuntu
10.04 from glassfish and I am able to execute the script from the servlet in tomcat6 in a
windows environment.  However, when I try to execute the script from the servlet in tomcat6
and Ubuntu 10.04 - nothing - even though I get the exit value of zero, I get the zero value
returned but no action from the script (all it does is open the default browser).

I have made the following changes in my tomcat installation:

Uncommented the following in the web.xml:



My tomcat-users:


  <role rolename="tomcat"/>
  <role rolename="role1"/>  
  <role rolename="manager"/> 
  <user username="tomcat" password="tomcat" roles="tomcat"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="role1" password="tomcat" roles="role1"/>
  <user username="tomcat" password="tomcat" roles="manager"/>  


Change made in context.xml:
<Context reloadable="true" privileged="true">

Added to system.policy:
// Grant WebApps All Permission
grant codeBase "file:/var/lib/tomcat6/webapps/-" {

Added to catalina.policy:
grant codeBase "file:${catalina.home}/webapps/GSMFilter/-"  { "/var/libs/tomcat6/webapps/GSMFilter/WEB-INF/storage/<<ALL
FILES>>", "read,write,execute,delete";

grant codeBase "file:${catalina.home}/webapps/GSMFilter/-"{

grant codeBase "file:${catalina.home}/webapps/GSMFilter/-"{
         permission java.lang.RuntimePermission "/home/troy/NetBeansProjects/GSMFilter/web/WEB-INF/storage/<<ALL
FILES>>", "read,write,execute,delete";




-----Original Message-----
From: Mark Thomas <>
To: Tomcat Users List <>
Sent: Sun, Aug 1, 2010 5:07 am
Subject: Re: Calling a CGI script from Servlet

On 01/08/2010 03:32, wrote:

> At this point I am at a loss.  Any help would be greatly appreciated.

With the information you have provided so far, I don't think anyone here

is going to be able to help you. As a minimum, you'll need to provide

the following:

- Tomcat version

- where CGI script is located

- what URL you are using to access it



To unsubscribe, e-mail:

For additional commands, e-mail:


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message