CGI 和 Tomcat
我正在尝试使用 tomcat 运行 cgi 脚本(.cgi)。 我收到以下错误,但无法找出问题所在。 我知道我真的应该使用 apache 和 mod proxy,但这确实不是我的专业领域,所以我采取了简单的方法!
谢谢你的帮助。
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)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这是猜测,但您可能需要将以下内容添加到
web.xml
文件中,以便 Tomcat 可以找到 perl 可执行文件。 显然,Tomcat 不会在您的PATH
中查找可执行文件:当然,请使用系统上 perl 的实际路径。
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 yourPATH
to find executables, apparently:Use the actual path to perl on your system, of course.
您需要在 servlet 元素中指定“可执行”参数。 根据 文档,默认为“perl”,这可能是触发你的错误的原因。 也许将其更改为 cmd.exe 之类的内容会起作用。
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.
该错误表明无法找到名为
perl
的可执行文件。 你的系统上安装了perl吗? 它在路径中吗?The error is indicating that the executable named
perl
cannot be found. Is perl installed on your system? Is it in the path?谢谢大家,我没有找到运行 C++ cgi 脚本的正确语法,但如果将参数留空,它将运行任何脚本类型。
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.
没有perl没有安装。 CGI脚本实际上是c++。 除了默认的 tomcat 安装之外,我没有安装任何其他东西。
No perl is not installed. The CGI script is actually c++. I haven't installed anything other than the default tomcat installation.