Search code examples
htmlnetbeanscgi

Simple cgi "Hello World" not found when recalled in a html form


I've got this simple .html form

<!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>

which should recall the CGI program in my /usr/lib/cgi-bin location.

Unfortunately an error shows up: Error: your file was not found

even though the file actually is in my folder: Present in the directory

Note that the CGI program is written in C and it's very simple:

#include <stdio.h>
int main() {
 printf("Content-type:text/plain\n\n");
 printf("Hello World!\n");
 return 0;
}
  • Where's the problem?

Solution

  • The first tab in the third image says file:///cgi-bin/test?.
    This suggests that what is not found is not the CGI on the server but a local file /cgi-bin/test.

    To resolve this problem, you have two choice:

    1. Put the HTML file on the server where the CGI is located and access it as the same site as the CGI.
    2. Change action in the HTML form from /cgi-bin/test to http://192.168.1.18/cgi-bin/test.