CGI and Perl - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

CGI and Perl

Description:

CGI is a lightweight mechanism for communication between the web server and ... use CGI::Carp qw(warningsToBrowser fatalsToBrowser); CGI and HTML ... – PowerPoint PPT presentation

Number of Views:202
Avg rating:3.0/5.0
Slides: 14
Provided by: babbageCs
Category:
Tags: cgi | carp | perl

less

Transcript and Presenter's Notes

Title: CGI and Perl


1
CGI and Perl
2
What is CGI?
  • CGICommon Gateway Interface
  • CGI is a lightweight mechanism for communication
    between the web server and other programs (CGI
    scripts) that can be run on the server.

3
CGI
  • Instead of pointing to an HTML file a URL may
    request that a CGI program is run on the server.
    CGI programs (or scripts) are commonly written
    in
  • Unix - Shell, Perl, Tcl, C,C, Python, Ruby
  • Windows - Visual Basic, Perl
  • Mac - Applescript, C,C, Perl

4
Client server schema I.
5
Client server schema II.
6
Client server schema III.
7
What is Perl?
  • Practical Extraction and Report Language
  • An interpreted language
  • Highly optimized for manipulating printable text
    but also able to handle binary data

8
Type of variable determined byleading special
character
  • scalar
  • _at_ indexed array lists
  • associative array
  • function

9
Two ways to sent data fromhtml form to CGI
  • GET-mainly used for short queries. Input values
    are part of URL
  • POST-will send data as input stream to the
    program
  • More secure

10
An example
  • http//babbage.cs.missouri.edu/cs2830/cgi-bin/co
    llect_student_data.cgi

11
Where should I put my CGIscripts?
  • CGI scripts must be under the public_html
    directory.
  • CGI scripts should be kept in separate
    subdirectory of the public_html directory tree.
    Ex. cgi-bin
  • CGI scripts must have a ".cgi" extension.
  • CGI scripts should have permissions of 705.
  • CGI scripts should live in directories that have
    permissions of 705.

12
How to run perl scripts on babbage
  • Perl is picky about permissions
  • use chmod to make them
  • either chmod 705 filename.cgi
  • or chmod uwrX,g-rwx,orx filename.cgi
  • To debug perl/cgi scripts in the browser, use
    this at the top of your scripts
  • !/usr/bin/perl -wprint "Content-type
    text/html\n\n"
    use CGIuse CGICarp
    qw(warningsToBrowser fatalsToBrowser)

13
CGI and HTML
  • If your CGI script is going to generate an HTML
    page, you must include this statement in the
    script
  • print "Content-type text/html\n\n"
Write a Comment
User Comments (0)
About PowerShow.com