Humour, comics, tech, law, software, reviews, essays, articles and HOWTOs intermingled with random philosophy now and then
Filed under:
Software and Technology by
Hari
Posted on Sat, Mar 22, 2008 at 17:39 IST (last updated: Wed, Jul 16, 2008 @ 20:38 IST)
Having used PHP as the logical choice for web development, I've always been a little mystified by cgi-bin scripts and never bothered to learn how they work. But no longer.
CGI scripts are nothing but scripts or executable programs. Apache simply executes them and renders the results. Of course, because every CGI program is an external application and requires the web server to start a new process, it makes the whole thing very processor intensive. The modern method of embedding scripts in web pages (most popularly PHP/ASP) which can be directly interpreted by Apache is a far more efficient method and I suppose more logical from a web designer's point of view.
However, there are still a few advantages to CGI scripts: you can use whatever language you wish to (plain shell scripting, Perl, Python and even compiled C executables). This offers many more options to the developer. Also in many cases CGI scripts are not limited to server "modules" and can directly use the underlying Operating System's functionality.
Rather than reinvent the wheel however, I'll point you to Apache's CGI tutorial which is a must read for any webmaster, web developer or server administrator.
Yes, CGI can be intimidating and complex CGI scripts can be a headache to maintain, but it's nevertheless useful to have an idea about how they work since so many websites still utilize this method of delivering dynamic content.
14 comment(s)
I'm currently learning python and might start diving into some mod_python for apache as well, really liking it over learning/getting better with Perl.
Comment by (visitor) on Sat, Mar 22, 2008 @ 18:29 IST #
In general, Python's documentation sucks. That is the biggest impediment to using that language instead of, say PHP or even Perl.
Comment by hari (blog owner) on Sat, Mar 22, 2008 @ 18:51 IST #
It was recommended by my boss as the better of the books to learn Python. You can read the entire thing online or download it. I also purchased it cause I'm weird like that and like hard copies of things when I'm away from a computer.
Comment by (visitor) on Sun, Mar 23, 2008 @ 02:32 IST #
Comment by hari (blog owner) on Sun, Mar 23, 2008 @ 07:48 IST #
Comment by drew (visitor) on Sun, Mar 23, 2008 @ 18:42 IST #
I feel it's more natural to use Python just as a plain programming language as it's intended to be and then use the modules required for web programming rather than learn another "framework" which has its own set of implementation rules.
Comment by hari (blog owner) on Sun, Mar 23, 2008 @ 20:34 IST #
Comment by od (visitor) on Sun, Mar 23, 2008 @ 21:28 IST #
I've already written a Python script to generate a website using text files.
Comment by hari (blog owner) on Mon, Mar 24, 2008 @ 07:42 IST #
Comment by RT Cunningham (visitor) on Mon, Mar 24, 2008 @ 11:45 IST #
While I believe Python and Perl have a lot of advantages over PHP going a bit deeper into them, PHP allows a lot of "lazy coding" too and is specifically targetted at "web designers" rather than "programmers". The biggest draw of PHP is its ability to be used as an embedded language so that it becomes very convenient to work around non-interpreted code (most commonly HTML or XML). Python and Perl for web development are not so intuitive but I think once you learn to use them, they can offer much more power and more maintainable code.
Python and Perl are much more traditional programming languages and web development is just one aspect of them.
Comment by hari (blog owner) on Mon, Mar 24, 2008 @ 12:43 IST #
I don't want to be some master programmer, but knowing a little bit of these help my career as a systems administrator.
Comment by (visitor) on Mon, Mar 24, 2008 @ 21:29 IST #
Comment by hari (blog owner) on Mon, Mar 24, 2008 @ 21:39 IST #
Comment by Joshua Goodwin (visitor) on Wed, Apr 2, 2008 @ 00:14 IST #
Think of it this way: PHP, ASP, JSP... etc. are languages that are embedded in documents (mostly HTML) and interpreted by the web server software directly (or through extensions like mod_php for Apache etc.)
CGI scripts are real programs (or scripts) that are called by the server software to run as a separate process and their output is returned to the server which then serves that as a web page.
Comment by hari (blog owner) on Wed, Apr 2, 2008 @ 08:29 IST #