Guidelines for HTML page generation by a CGI-program

  1. In order for your program to send its standard output to the Web it should be placed in a special directory on the web server, that is the cgi-bin directory inside the public_html directory (/home/username/public_html/cgi-bin/).

    You can define directories in which you would like cgi scripts to run.

    Consult the apache2 web server guide.

  2. If your program output is a text file (e.g. in HTML format), you must include in your program the following print command before any other print commands:
    print "content-type: text/html\n\n";
  3. Remember to use <BR> or <P> tags to mark end of text lines.
    \n "newlines" will not be visible on Web pages.

  4. In quoted strings, remember to place a backslash before quotes. e.g.
    print "<A HREF=\"home.html\">Back to Home Page</A>";

  5. Do not forget to make the file containing your program (e.g. hello.cgi) executable by "the world" using the Unix command:
    chmod +x hello.cgi
  6. To execute your program from a Web browser, use the following URL (assuming that your program is in your public_html directory):
    Where userid is your own userid.

Table of Contents.
Previous | Next.