0
votes

I have a system with Ubuntu10.04 Operating System.
I have my Apache tomcat(6.0.29) installed at /usr/local/tomcat/
I have one python script hello.py
I would like to run this python script inside cgi-bin.
Python is at /usr/bin/python
My application I am running is eegis which is running fine.
http://localhost:8080/eegis/index.html

I have already searched in net a lot it is saying you have to configure web.xml with following configuration.

<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> 
<init-param> 
<param-name>executable</param-name> 
<param-value>/usr/bin/python</param-value> 
</init-param> 
<init-param> 
<param-name>passShellEnvironment</param-name> 
<param-value>true</param-value> 
</init-param>
<load-on-startup>5</load-on-startup> 
</servlet>

I have uncommented this also

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

I have done this but still I am not able to run python script.
While trying http://localhost:8080/eegis/cgi-bin/hello.py

I am getting this error

HTTP Status 404 - /eegis/cgi-bin/
type Status report
message /eegis/cgi-bin/
description The requested resource (/eegis/cgi-bin/) is not available.
Apache Tomcat/6.0.29

1
The problem has been resolved now. Still I will share my experience. The first problem was with my python script I had forgot to insert "\n\n" (print "Content-type: text/html\n\n") [mid it \n\n immediatetle after header without any spaces (print "Content-type: text/html \n\n") this will not work]at the end of the content description header. Second I have saved the file as .py but it should be .cgi every thing else was fine. My scripts are executing now. Thanks - LotusCloud

1 Answers

-1
votes

The problem has been resolved now. Still I will share my experience. The first problem was with my python script I had forgot to insert "\n\n" (print "Content-type: text/html\n\n") [mid it \n\n immediatetle after header without any spaces (print "Content-type: text/html \n\n") this will not work]at the end of the content description header. Second I have saved the file as .py but it should be .cgi every thing else was fine. My scripts are executing now. Thanks