CGI 和 Tomcat

发布于 2024-07-13 04:38:23 字数 934 浏览 3 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

篱下浅笙歌 2024-07-20 04:38:23

这是猜测,但您可能需要将以下内容添加到 web.xml 文件中,以便 Tomcat 可以找到 perl 可执行文件。 显然,Tomcat 不会在您的 PATH 中查找可执行文件:当然,

executable
C:\perl\bin\perl

请使用系统上 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 your PATH to find executables, apparently:

executable
C:\perl\bin\perl

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

风和你 2024-07-20 04:38:23

您需要在 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.

半仙 2024-07-20 04:38:23

该错误表明无法找到名为 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?

时光磨忆 2024-07-20 04:38:23

谢谢大家,我没有找到运行 C++ cgi 脚本的正确语法,但如果将参数留空,它将运行任何脚本类型。

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

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>
一直在等你来 2024-07-20 04:38:23

没有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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文