1. Trang chủ
  2. » Giáo án - Bài giảng

Internet intrarnet CIS class 8

26 142 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Internet / Intranet CIS-536 Class Perl / CGI Scripting Class Agenda CGI Scripting Perl Telnet / UNIX Lab Work Telnet Basic UNIX Perl CGI / Scripting Scripts are Programs Run By the Server CGI – Common Gateway Interface Methodology For Server/Script Communication Can Be Written in Any Language Supported By the Server UNIX Origins PERL is Most Common Script Output is Returned to the Browser Alternative Methodologies Exist CGI is the Most Portable PERL – Practical Extraction and Reporting Language UNIX Based Scripting Language Ported to Multiple Platforms How Does Browser Know to Execute a Program? Program is in a Script Directory Typically cgi-bin (Apache) Or By Extension (e.g .pl, cgi) Scripts Must Have Executable Permissions Scripting Features Scripts Can Have Input Parameters Passed as Part of URL : ? Argument (Query String) Special Characters Passed as % Ascii Hex Values Name/Value Pairs : Separated by & Variable Passed in HTTP Header Name/Value Pairs Method = Post HTML Forms Passed in Cookies Netscape Origins, Now Widely Adopted Name/Value Pairs Associated With a URL Stored on Client Computer Users May Turn off Cookies Scripts Must Be Aware of How Parameters are Being Passed Different Methodology to Access Each Method Parameters Also Used to Maintain State Information Help Track a “Session” Scripting Issues Security Concerns No Limits on What CGI Scripts May Access Potential to Execute Any System Command Hacker Can Cause Serious and Unforeseen Problems Potential to Affect More Than Just Your Web Site Many ISP’s Limit CGI Capabilities Performance Concerns CGI Scripts are Run as a Standalone Process E.g Interpreter is Loaded and Initialized Each Time Alternative to Posting Forms Mailto Option Perl Why Should I Learn Perl? S/W Engineers Need to Be Adept at Picking Up New Languages Need a “Comfort Level” of Expertise Ability to Write Basic Code Ability to View/Modify Existing Code Ability to Learn More as Needed Develop Reference “Library” Develop “Guru” Network Large Public Archives of Perl Scripts Perl Basics Interpreted Originally Used Primarily By UNIX Sys-Admins “Public Domain” The preferred language for CGI Scripts PERL is Relatively Portable Activestate ActivePerl (Windows / IIS) UNIX specific scripts dominate (Uses UNIX O/S Commands) Perl 101 C-like Lines end with ; Syntax of Print statement is very similar Pointers and indirection VB-like Untyped (except for arrays) Associative arrays UNIX-like “Tricks” e.g $a = retrieves a line of input from stdin support for regular expressions doublequotes vs singlequotes all examples must contain foo Perl-Like Variables begin with $ Comments begin with # Subroutines Begin with & Associative Arrays Begin with % Perl 102 Powerful Features Can run “command line” commands on O/S (system, `xxx`) Can create code on the fly (eval) Subroutine Libraries Powerful Features Make it a Target of Hackers Print is the Most Important Command Generate HTML Using Print Statements print “text to print \n” Don’t forget carriage returns: \n First Line: #! /usr/local/bin/perl Output has Mime content-type as first line, blank line print “Content-type: text/html \n\n”; A Simple Perl Example #! /usr/local/bin/perl # First Perl $myname=“Evan”; print

Ngày đăng: 08/01/2018, 16:31

Xem thêm:

TỪ KHÓA LIÊN QUAN

Mục lục

    A Simple Perl Example

    Class Exercise: First Perl

    Common Basic UNIX Commands

    The UNIX chmod Command

    Processing Forms – The Server Side

    ReadParse Subroutine in cgi-lib

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w