Objective INT322 Monday, January 19, 2004 By the end of this week you will: (1)understand the interaction between a browser, web server, web script, interpreter, and database server. (2) know what Perl is and why it is used on the web. Today Announcements From Last Week... Browser Interactions Quiz Announcements See me for your account if you don t have one yet. Exercise 1 due Friday, January 23 Post a message on Blackboard Edit your Zenit homepage Attending the other section of the course... Web Sites: Reminder Blackboard - Marks, Discussion http://my.senecacollege.ca/ INT322 Web Site http://cs.senecac.on.ca/~int322/ Web Sites: Reminder Instructor s Home Page http://cs.senecac.on.ca/~ctyler/ Instructor s Zenit Home Page http://zenit.senecac.on.ca/~tyler/ Building on Last Session... bash script interpreter Pathnames Review... Absolute Relative Relative-to-home
Namespace Mapping Web pathnames vs. file pathnames Translation of namespaces Not necessarily 1:1 Web Interactions - Static Browser -> Apache Apache <-> Filesystem Apache -> Browser Web Interactions - Static Browser -> Apache http(+content) Apache <-> Filesystem Apache -> Browser http+content Web Interactions - Dynamic Browser -> Apache http(+content) Apache <-> Filesystem Apache -> OS exec() CGI(+content) OS exec() -> Interpreter Interpreter -> Script Script -> Apache CGI+http+content Apache -> Browser http+content Web Interactions - HTTP Header Format HTTP Headers are based on...? Web Interactions - HTTP Header Format HTTP Headers are based on... RFC822 (E-mail) Method/status Header1: value Header2: value blank line Body of message Web Interactions - Request Headers (Browser) Web Interactions - Response Headers (Server) GET / HTTP/1.1 Host: zenit.senecac.on.ca blank line HTTP/1.1 200 OK Date: Mon, 09 Sep 2002 14:49:09 GMT Connection: close Content-Length: 1761 Content-Type: text/html blank line <xml...
MIME-Types MIME-Types MIME MIME stands for...? MIME Multimedia Intenet Mail Extensions Format of the content type header? MIME-Types Common MIME-Types MIME Multimedia Intenet Mail Extensions Raw text: Content-type: type/subtype Common MIME-Types Common MIME-Types Raw text: text/plain xhtml: Raw text: text/plain xhtml: text/html PNG graphic: Common MIME-Types Common MIME-Types Raw text: text/plain xhtml: text/html PNG graphic: image/png Ogg Vorbis song: Raw text: text/plain xhtml: text/html PNG graphic: image/png Ogg Vorbis song: audio/ogg MPEG film:
Common MIME-Types Raw text: text/plain xhtml: text/html PNG graphic: image/png Ogg Vorbis song: audio/ogg MPEG film: video/mpeg CGI CGI Stands for? CGI Common Gateway Interface CGI Defines...? CGI Common Gateway Interface Defines server <-> script interaction How many paths? CGI Common Gateway Interface Defines server <-> script interaction 4 paths (2 each direction) What are the paths? CGI Common Gateway Interface Defines server <-> script interaction 4 paths (2 each direction) stdin stdout stderr environment variables Stdin, Stdout, Stderr Stdin, Stdout, Stderr Stdin post form element values from browser via Apache Stdout headers, content to browser via Apache Stderr error message to logfiles via Apache (usually) Environment Variables client and server details query-string value from URI
Basic CGI Program Requirements Basic CGI Program Requirements 1. Must be executable by? 1. Must be executable by the web server. 2. Must output? Basic CGI Program Requirements Basic CGI Program Requirements 1. Must be executable by the web server. 2. Must output at least one header followed by a blank line (usually the Content-type header). 3. Must finish executing before? 1. Must be executable by the web server. 2. Must output at least one header followed by a blank line (usually the Content-type header). 3. Must finish executing before anything is sent. A Word on Web Design & CGI A Word on Web Design & CGI Many sites have good programming or good design. The two are not mutually exclusive! A good E-Commerce site should have: Consistent navigation Feedback on WHERE you are Location in the process Colour & graphical mode cues What is Perl? Quiz! Perl is an acronym for "Practical Extraction and Report Language". started out as a scripting language to supplement rn, the USENET reader created by Larry Wall.
What is Perl? Perl History: 1987 Perl: is an interpreted language is optimized for string manipulation, I/O and system tasks. has built-in functions for almost all Unix system commands. Larry Wall posted Perl 1.0 to the usenet group comp.sources. Perl History: 1988 Perl History: 1989 Perl 2.0 is released with more text processing enhancements. Perl 3.0 is released under the GNU General Public License. The open source community works on creating many modular extensions. Perl History: 1990 Perl History: 1991 Tom Christiansen s The Answer to All Man s Problems is published. Programming Perl, by Larry Wall and Randal L. Schwartz, is published by O Reilly & Associates (the Camel) Perl 4.0 is released under the GPL and the new Perl Artistic License. Perl History: 1992 Perl History: 1993 MacPerl is released (non-mac interface). Final version of Perl 4 released. MacPerl 4.1.0 has true Mac interface. Perl community picks up steam -- mailing lists. Learning Perl by Randal L. Schwartz is published.
Perl History: 1994 Perl History: 1995 Perl 5 is born. Perl 5 was a major reorganization that fixed may of the language s limitations. First recorded Perl CGI script. Work on CPAN begins in earnest. Tim Bunce introduces DBI/DBD. Perl History: 1996 Perl History: 1997 The Perl Institute (TPI), a not-for-profit perl advocacy organization, is created. The Perl Institute announces a web-accessible mirror of CPAN. The Perl Journal publishes its first issue. Perl History: 1998 Perl History: 1999 Perl Mongers is incorporated as a not-for-profit in New York state. CPAN grows to 100 mirror sites. ActiveState Tool Corp. announces a corporate support package for Perl called PerlDirect. Perl s usage in developing web applications grows. Perl History: 2000 Perl History: 2001 Perl 5.6 is released for Windows, Solaris and Linux with Unicode support. Perl 5.6.1 is released. Version number: <major>.<minor>.<path> Work on Perl 6 begins. Perl 6 is a major rewrite Separates compiler from runtime (Parrot)
Perl History: 2002 Why Perl for web development? Perl 5.8 released with strong Unicode support. CGI (the Common Gateway Interface) and Perl. Work on Perl 6 continues. Perl is rapidly developing. Text processing strength good match for web. Why Perl for web development? Why Perl for web development? Free language, many online resources. Interpreted - fast debug cycle. Integrates well with Internet protocols. Extensible using modules. Links http://www.perl.org/ http://www.perl.com/ http://www.cpan.org/ http://www.opensource.org/licenses/ Is Perl Installed? Is Perl installed? What is the path? Needed for #! Demonstration... What Version is Installed? Getting and Installing Perl: Availability Current version is 5.6.1 -v argument reports version -V gives installation details Available under GPL and/or Artistic License. Standard in RedHat, Slackware and SuSE. Downloadable as source & binary.
Common Download Sites Acquiring and installing Perl http://www.perl.com/ http://www.cpan.org/ Use vendor distribution first. Otherwise use perl.com/cpan.org source or binaries. Installing from Source gunzip stable.tar.gz tar xvzf stable.tar follow README and INSTALL files Install from Source./Configure make make test make install (as root) Installing from Binaries Modules RPMs: rpm -i ActivePerl-5.6.1.631-i686-linux.rpm A module is a collection of functions. Several included in core distribution. Modules Installing Modules Three types: Pragmatic Library Object Obtain from CPAN gunzip yourmodule.tar.gz tar xvf yourmodule.tar perl Makefile.PL make make test make install
Automated Install perl -MCPAN -e shell get make test install readme