tags:

views:

940

answers:

7

Hello, im trying to run a cgi script (.cgi) with tomcat. I am getting the below error and cant find out whats wrong. I know i should really use apache and mod proxy but this really isnt my area of expertise so im taking the easy way out!

Thanks for any help.

java.io.IOException: Cannot run program "perl" (in directory "C:\Java\tomcat\webapps\my_app_name\WEB-INF\cgi"): CreateProcess error=2, The system cannot find the file specified
    java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
    java.lang.Runtime.exec(Runtime.java:593)
    java.lang.Runtime.exec(Runtime.java:431)
    org.apache.catalina.servlets.CGIServlet$CGIRunner.run(CGIServlet.java:1705)
    org.apache.catalina.servlets.CGIServlet.doGet(CGIServlet.java:597)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:416)
A: 

This is something of a guess, but you might need to add the following to your web.xml file so that Tomcat can find the perl executable. Tomcat doesn't look in your PATH to find executables, apparently:

executable
C:\perl\bin\perl

Use the actual path to perl on your system, of course.

Adam Bellaire
A: 

The error is indicating that the executable named perl cannot be found. Is perl installed on your system? Is it in the path?

Jason Day
A: 

No perl is not installed. The cgi script is actually c++. I havent installed anything other than the default tomcat installation.

+1  A: 

You need to specify the "executable" parameter in the servlet element. According to the documentation, the default is "perl", which is probably what is triggering your error. Maybe changing it to something like cmd.exe will work.

Tore A.
A: 

Thanks everyone, i didnt find out what was the correct syntax to run C++ cgi scripts, but if you leave the param blank it will run any script type.

<init-param>
  <param-name>executable</param-name>
  <param-value></param-value>
</init-param>
A: 

hello alan you are a genius :D

lapusan
A: 

Hi Guys , Thanks Adam!! Your sugestion worked. I was getting the same error on WinXP, Tomcat5.5 and ActivePerl setup.

java.io.IOException: Cannot run program "perl" (in directory "C:\Java\tomcat\webapps\my_app_name\WEB-INF\cgi"): CreateProcess error=2, The system cannot find the file specified

Adam is absuolutely right that on windows machine Tomcat does not take Enviroment Path of OS. Executbale's absolute path is neede

<init-param>
<param-name>executable</param-name>
<param-value>C:\perl\bin\perl.exe</param-value>
</init-param>

This worked for me. :-)Thanks!!

Gyan Prakash