How is html code read, compared to say python?

so, the first line of bash, perl, python, ruby, and similar languages must contain the path to the interpreter...i.e. #!/bin/perl, or #!/bin/python. so in the case of a perl script, for instance, a perl script cannot and will never run if the perl program is not installed/present on the system. same thing with python and others.

now, im curious, how is html code being read? what program on the system (let's assume its a Unix system) must exist for an html page to be read and processed?

By a web server. Apache on most Linux/Unix systems, and IIS (Internet Information Server) on Microsoft operating systems.
You can also open an html file with a web browser if you have read access to the file.

HTML is �read� by parsing the markup language based on standards and rendering ths results.

Also, web servers like Apache2 and ISS process HTTP , transferring (not processing) HTML.

Are you talking about in the context of a file manager? So you go into a folder and you can see by the icons that you have a perl script, or a python script, or an html file; and clicking on the icon will run the script or open the html file in a browser?

Andrew

Actually, SkySmart was asking about the Shebang in scripts and comparing to HTML.

However, some of the things SkySmart said were not true, for example: "the first line of bash, perl, python, ruby, and similar languages must contain the path to the interpreter"...

This is not always true, as I can easily execute a PHP script from the command line by calling:

php filename.php

and the path to the interpreter is not required to execute the code. The same is true for most scripts when executed directly.

HTML isn't a scripting language. It's not a programming language, but a markup language 'a system for annotating a document in a way that is syntactically distinguishable from the text' (see wikipedia). Therefor a shebang doesn't make any sense.

HTML has a kind of �shebang� ... its the HTML directive that tells the browser what version of HTML is encoded.

So Yes HTML does not have a shebang that designates the script interpreter. HTML does have a designator for HTML interpretation, as does XML etc.

HTML sort of has a shebang and sort of doesn't. It has something web browsers understand, but doesn't have a UNIX shebang, so ./file.html would just default to 'shell script' and quit with loads of errors.

If you added the shebang #!/usr/bin/php it would work, but only because PHP was designed to operate on HTML!

In short, HTML is not handled at the shell level in UNIX. What you're looking for is in Apache or whatever other web server you have.

Most has already been said, but to summarise:

  1. html - read as a file - read by a browser from a filesystem and rendered into a doc
  2. html - read as a file - read by a web server and streamed to network socket (remote connection)
  3. html - read as a stream - read by a browser from a network socket (website connection) and rendered into a doc
  4. html - read as a stream - passed by a cgi script to a web server to be streamed to a remote connection
  • html is text.
  • An html doc content is sandwiched between the tags <html> </html>

One thing though - html rendering or streaming applications use an additional tag to switch them into "html handling mode" (like a tag that printer streams needed to go into postscript or pcl printing mode)

If you write a cgi in shell/perl/php your text stream needs this at the front:

Here is an example.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "blah blah had to remove the link">

I bet there are more options but these are the basics as far as I can tell.