【问题标题】:Simple cgi "Hello World" not found when recalled in a html form以 html 形式调用时未找到简单的 cgi“Hello World”
【发布时间】:2019-10-27 12:33:43
【问题描述】:

我有这个简单的 .html 表单

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <form action="/cgi-bin/test">
        <input type="text" placeholder="Your name here">
        <input type="submit" value="Conferma">
    </form>
</body>
</html>

这应该会在我的/usr/lib/cgi-bin 位置调用 CGI 程序。

不幸的是,出现了一个错误: Error: your file was not found

即使文件实际上在我的文件夹中: Present in the directory

请注意,CGI 程序是用 C 编写的,非常简单:

#include <stdio.h>
int main() {
 printf("Content-type:text/plain\n\n");
 printf("Hello World!\n");
 return 0;
}
  • 问题出在哪里?

【问题讨论】:

    标签: html netbeans cgi


    【解决方案1】:

    第三张图片中的第一个标签显示file:///cgi-bin/test?
    这表明未找到的不是服务器上的 CGI 但是一个本地文件/cgi-bin/test

    要解决此问题,您有两种选择:

    1. 将 HTML 文件放在 CGI 所在的服务器上,并作为与 CGI 相同的站点访问它。
    2. 将 HTML 表单中的 action/cgi-bin/test 更改为 http://192.168.1.18/cgi-bin/test

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-01-17
      • 2019-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 1970-01-01
      相关资源
      最近更新 更多