CSE 102 Introduction to Web Design and Programming

Slides:



Advertisements
Similar presentations
CS 142 Lecture Notes: HTMLSlide 1 Introduction There are several good reasons for taking CS142: Web Applications: ● You will learn a variety of interesting.
Advertisements

CS 898N – Advanced World Wide Web Technologies Lecture 6: PERL and CGI Chin-Chih Chang
Guide To UNIX Using Linux Third Edition
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
2 1 Sending Data Using a Hyperlink CGI/Perl Programming By Diane Zak.
Python CGI programming
Introduction to Programming the WWW I CMSC Summer 2004 Lecture 6.
The Web A Resource for All of Us Introduction Objectives Recall the history of computers: before 1950, Internet, personal computers Identify the purpose.
CSU - DCE Advanced Perl CGI Operation - Fort Collins, CO Copyright © XTR Systems, LLC Introduction to the Common Gateway Interface (CGI) on the.
ASP Introduction Y.-H. Chen International College Ming-Chuan University Fall, 2004.
Building PERL Scripts on a Windows system* *and running those scripts on an Apache server!
1 Basic Perl CGI Programming. 2 Issues How and when your program is invoked. Generating Response –HTTP Headers –HTML (or whatever document type you want)
Chapter Nine Perl and CGI Programming. 2 Objectives Basic features of Perl language Set up an HTML Web page Use Perl and CGI scripts to make your web.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
7 1 User-Defined Functions CGI/Perl Programming By Diane Zak.
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
Accessing the Lab. Putty Available via links on course page Creates secure (SSH) command line session between your machine and SCS network Uses tunnelling.
Introduction to Perl. What is Perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Similar to shell script.
CIS 375—Web App Dev II JavaScript I. 2 Introduction to DTD JavaScript is a scripting language developed by ________. A scripting language is a lightweight.
Copyright 2007 Byrne Reese. Distributed under Creative Commons, share and share alike with attribution. 1 Intermediate Perl Programming Class Two Instructor:
ICE UNIX TUTORIAL. File System Commands cd – change directory cd – change directory ls – list contents ls – list contents rm – remove/delete rm – remove/delete.
University of Kansas Department of Electrical Engineering and Computer Science Dr. Susan Gauch April 21, 2005 I T T C Introduction to Web Technologies.
File Uploads and Cookies Pat Morin COMP Outline File upload Cookies.
What is XHTML? XHTML stands for Extensible Hypertext Markup Language
Chapter 7 - Introduction to Common Gateway Interface (CGI)
CSE 102 Introduction to Web Design and Programming
CSE 102 Introduction to Web Design and Programming
HTML 5.
CSE 102 Introduction to Web Design and Programming
CIS 228 The Internet 9/20/11 XHTML 1.0.
JavaScript: Control Structures I
CSE 102 Introduction to Web Design and Programming
CSE 102 Introduction to Web Design and Programming
CGI, FORMS and Perl CSC 3750 Fall
Introduction to PHP FdSc Module 109 Server side scripting and
PERL.
You and your (DNA) parasites
DBW - PHP DBW2017.
Programming Basics Web Programming.
How to create and run CGI programs using the CS web server.
Using the Internet to publish data and applications
Introduction to Programming the WWW I
XHTML 1 by Carsomyr.
Perl Web Page – Just Enough
CGI Programming Part II UNIX Security
XHTML
Chapter 8 - JavaScript: Control Structures I
Chapter 9 - JavaScript: Control Structures II
Introduction There are several good reasons for taking CS142: Web Applications: You will learn a variety of interesting concepts. It may inspire you to.
Perl Practical Extraction and Report Language
CS 142 Lecture Notes: Rails Controllers and Views
Web Programming Essentials:
Instructor: Charles Moen
Note that iframes are available in HTML5.
Web Server Design Week 15 Old Dominion University
CS 142 Lecture Notes: Rails Controllers and Views
Perl Practical Extraction and Report Language
Chapter 7 - JavaScript: Introduction to Scripting
You and your (DNA) parasites
Perl Practical Extraction and Report Language
XHTML 7-May-19.
Dreamweaver.
XHTML Basics.
Web Server Design Week 14 Old Dominion University
XHTML 29-May-19.
Chapter 8 - JavaScript: Control Structures I
CGI II: Cookies & Stuff Web Programming.
PHP By Prof. B.A.Khivsara Note: The material to prepare this presentation has been taken from internet and are generated only for students reference and.
Web Design & Development
Creating Web Documents
Presentation transcript:

CSE 102 Introduction to Web Design and Programming Perl & CGI

What is Perl? The Practical Extraction & Report Language Open Source (1987) freely available for downloading from the Comprehensive Perl Archive Network www.perl.com it is already installed on Sparky The Perl scripting language has many uses, for us: Web CGI programming (like we’ve been doing)

What can you do with Perl Lots: scalar variables arrays mathmatical arithmetic string operations boolean arithmetic conditional statements standard I/O file I/O interprocess I/O iteration functions

Script File Issues When transfering files from Windows to Unix, some encoding issues So, we can use Pico in Unix, to use: Open SSH Terminal Window and login cd www cd cgi-bin ls pico filename Once pico opens, you may begin typing Commands: CTRL-O to save (look at bottom of screen) CTRL-X to exit Also, make sure all files have 755 file permissions

CookieMonster.html <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Domain Name Availability Check</title> </head> <body> <h2>A Cookie Demo</h2> <h3>The Cookie Monster wants to know</h3> <form method="post" action="http://www.sinc.sunysb.edu/cgi-bin/cgiwrap/aesmaili/cookiemonster.pl" enctype="application/x-www-form-urlencoded"> <p>What sort of cookies do you like? <input name="cookie_type" size="16" type="text" /> <input type="submit" value="Submit" /> </p> </form> </body> </html>

cookiemonster.pl #!/usr/local/bin/perl -T use CGI qw(:standard); $ENV{'PATH'}='/usr/sbin:/sbin:/bin:/usr/bin'; delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; ## script values REPLACE aesmaili with YOUR USERNAME $cookie_path = '/cgi-bin/cgiwrap/aesmaili/cookiemonster.pl'; $whois="/usr/bin/whois"; ##### in-script configuration values END $cookie_type=param('cookie_type'); ## set cookie $the_cookie = cookie(-name=>'TheCookieMonsterCookie!!!', -value=>$cookie_type, -expires=>'+100000h', -path=>$cookie_path); # Print the cookie header with expiration date print header(-cookie=>$the_cookie, -charset=>'UTF-8'); ##### send HTML page outputFile(); ################# subroutines ##################### sub outputFile { print <<END; <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head><title>Cookie Response</title></head> <body style="background-color:blue; color:white"> <h3>The Cookie Monster knows you like $cookie_type cookies</h3> <p>I put a cookie on your computer</p> </body> </html> END } cookiemonster.pl

FileUploader.html <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>File Uploader</title> </head> <body> <p style="font-weight: bold; font-size: larger"> Upload a picture</p> <form method="post" action="http://www.sinc.sunysb.edu/cgi-bin/cgiwrap/aesmaili/fileuploader.pl" enctype="mulipart/form-data"> <input type="file" name="yourpic" /><br /> <input type="submit" value="Submit" /> </form> </body> </html>

fileuploader.pl #!/usr/bin/perl use CGI qw(:standard); ## cgi perl module $query = new CGI; var $name = param('yourpic'); $fh = $query->upload($name); binmode(fh); binmode(OUT); while ( <$fh> ) { print OUT; } close OUT; print "Content-type: text/html\r\n\r\n"; print <<END; <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head><title>File Uploading</title></head> <body> <h3>File Uploaded: $name</h3> <p><img src="$name" /></p> </body> </html> END fileuploader.pl