tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Pyeron" <jpye...@pdinc.us>
Subject RE: Calling a CGI script from Servlet
Date Sun, 01 Aug 2010 13:19:28 GMT
 

> -----Original Message-----
> From: troylparrish@aol.com [mailto:troylparrish@aol.com] 
> Sent: Sunday, August 01, 2010 8:19
> To: users@tomcat.apache.org
> Subject: Re: Calling a CGI script from Servlet
> 
> 
> 
> 
> 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/helloWor

Do you mean /home?

> ld.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.h
tml). ; 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/<<A
LL FILES>>", "read,write,execute,delete";
> 
>  


--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-                                                               -
- Jason Pyeron                      PD Inc. http://www.pdinc.us -
- Principal Consultant              10 West 24th Street #100    -
- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -
-                                                               -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This message is copyright PD Inc, subject to license 20080407P00.



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


Mime
View raw message