我在cgi-bin文件夹中有一个名为helo.jar
的可执行jar文件和一个hello.sh
这是我的脚本
#!/bin/bash
java -jar helo.jar
我尝试通过此网址"http://localhost/cgi-bin/hello.sh"运行此脚本
遇到内部服务器错误,并检查日志,它说"标头之前的脚本输出结束">
我正在使用可以执行java命令的docker wordpress容器,我是cgi程序的新手。
这是我的Java代码
public static void main( String args[] )
{
// Here is a minimalistic CGI program that uses cgi_lib
// Print the required CGI header.
System.out.println(cgi_lib.Header());
// Parse the form data into a Hashtable.
Hashtable form_data = cgi_lib.ReadParse(System.in);
// Create the Top of the returned HTML page
System.out.println("Here are the name/value pairs from the form:");
// Print the name/value pairs sent from the browser.
System.out.println(cgi_lib.Variables(form_data));
System.out.println("Nome: " + form_data.get("name"));
System.out.println("<p>");
System.out.println("Email: " + form_data.get("email"));
System.out.println("<p>");
System.out.println(cgi_lib.HtmlBot());
}
我确定我的错误在我的脚本中,因为我已经尝试了其他脚本并且它有效,例如使用 perl
为了使脚本在所有机器上工作,它必须用UNIX编写,这可能是问题所在。
要解决此问题,您可以:
- 如果您有记事本+,请转到设置,首选项,新文档并切换到UNIX;
-如果你有一个虚拟机,你可以简单地做:回显一些> name.sh 的东西;
你有没有在你的Java代码中尝试过这个?
#!/usr/bin/java --source 11