tomcat-users mailing list archives

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



Mark,

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/helloWorld.py",
"-c"};
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);

MY ORIGINAL POST: 

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 (http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html).
; 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:

 <servlet>
        <servlet-name>cgi</servlet-name>
        <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
        <init-param>
          <param-name>debug</param-name>
          <param-value>0</param-value>
        </init-param>
        <init-param>
          <param-name>cgiPathPrefix</param-name>
          <param-value>WEB-INF/cgi</param-value>
        </init-param>
         <load-on-startup>5</load-on-startup>
    </servlet>

<servlet-mapping>
        <servlet-name>cgi</servlet-name>
        <url-pattern>/cgi-bin/*</url-pattern>
    </servlet-mapping>

My tomcat-users:

<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"/>  

</tomcat-users>

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/-" {
    permission java.security.AllPermission;
};

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

grant codeBase "file:${catalina.home}/webapps/GSMFilter/-"{
    permission java.security.AllPermission;
};

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 <markt@apache.org>
To: Tomcat Users List <users@tomcat.apache.org>
Sent: Sun, Aug 1, 2010 5:07 am
Subject: Re: Calling a CGI script from Servlet


On 01/08/2010 03:32, troylparrish@aol.com 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











Mark























---------------------------------------------------------------------





To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org





For additional commands, e-mail: users-help@tomcat.apache.org












 
 

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