ITC 250/CPET 499 Web Systems
Homework Assignment #8
Assigned Date: Nov. 20, 2013
Due Date: Dec. 3, 2013 before 3:00 PM (as email attachments)
Individual assignment
Perl CGI Server-Side Perl Script Programming Exercises through XAMPP for Windows installed at your own computer.
Part 1. Understand your XAMPP configuration and locate your Perl.exe setup location
According to http://www.apachefriends.org/en/xampp.html , the XAMPP is a free and open source cross-platform server solution stack package which consists of the Apache HTTP server, MySQL database, PHP and Perl etc. Reexamine your installation and answer the following:
A. Where is the folder (directory) for storing the server homepage and all related web pages? (Give the complete path or your installation)
B. Find the folder and path for the install perl.exe.
C. Start your Windows’ command , by clicking the Windows’s icon located on lowest-left task-bar,
a) then enter “cmd” in the command box, to see the command window; at the command prompt
b) use “cd /” command to move to the root of C drive
c) use “cd xampp/perl” command to move to the perl installation folder or directory
d) Then enter the following command to see the installed perl.exe application and it’s version: “perl –v”
e) Copy the installation message for use in your lab report
Part 2. Understand Perl programming environment, program editing and testing
A. Copy the test1.pl located on Example 1-1 (Chapter 1. Web Servers and CGI/Programming, http://www.etcs.ipfw.edu/~lin/Presentation/Perl/1_CGI.htm ) to notepad editor, and save it into c:\xampp\cgi-bin folder
· Move to c:\xampp\cgi-bin folder, by typing the following two commands
cd ..
cd cgi-bin
· Then verify you can run Perl at this c:\xampp\cgi-bin folder, by typing “perl -v”
· Run the test1.pl script by typing the following command
perl test1.pl
· Copy the script running result for use in your lab report
B. Use the notepad to edit the Perl program: printex.pl as shown in Chapter 2. Perl Programming Environment:http://www.etcs.ipfw.edu/~lin/Presentation/Perl/2_Perl_IntroNoDiagram.htm )
· Save the printex.pl into c:\xampp\cgi-bin folder
· Use the command “dir” to see all save perl program
· Run this program, by typing
perl printex.pl
· Save the result for use in the lab report
Part 3. Perl CGI Programming Exercises
A. Star your Apache HTTP server through XAMPP control panel
B. Copy hello.pl program as shown in Example 1-2 (http://www.etcs.ipfw.edu/~lin/Presentation/Perl/1_CGI.htm) into Notepad editor
a) Change the first line of the program #!/usr/bin/perl to #!”c:\xampp\perl\bin\perl.exe” where the Perl.exe located in the XAMPP, and note that the pair of double quotes is required.
b) Save it in the c:\xampp\cgi-bin folder
c) Open an Internet Explorer browser, enter http://localhost/cgi-bin/hello.pl , observe and save the running results for lab report.
d) Repeat the same test using Google Chrome browser and Mozilla Firefox browser
C. Copy browserinfo.pl (Example 3-1 of Chapter 3. CGI Environment Variables, http://www.etcs.ipfw.edu/~lin/Presentation/Perl/3_CGIParaCcess.htm ), and edit the first line statement which shows the path to the HTTP Webserver for where the Perl.exe is located; repeat the same testing process as shown in Part 3. B.
D. Find the printenv.pl located in c:\xampp\cgi-bin folder, open it with Notepad editor
#!"C:\xampp\perl\bin\perl.exe"
##
## printenv -- demo CGI program which just prints its environment
##
print "Content-type: text/plain; charset=iso-8859-1\n\n";
foreach $var (sort(keys(%ENV))) {
$val = $ENV{$var};
$val =~ s|\n|\\n|g;
$val =~ s|"|\\"|g;
print "${var}=\"${val}\"\n";
}
a) Run the printenv.pl program using IE browser, by entering the following
http://localhost/cgi-bin/printenv.pl
b) Study the related link shown in Nov. 19’s lecture note, for CGI Environment Variables that shows: Document Root, HTTP Server Name, Server Port, Server Protocol, Version of HTTP protocol, Home of MySQL database, Request URI. Use those info for your report.
Hand In Requirement
· Prepare your homework 8 report “hw8.docx” using format “ECET Laboratory Report Guidelines, http://www.etcs.ipfw.edu/~lin/InfoForAllCourses/laboratoryreport.htm ”, include all the information, copy and paste: source code Perl scripts, running results; also don’t forget add your Lesson learned and summary.
· Submit your hw8.docx to Prof. Lin’s email at lin@ipfw.edu before 3 PM, Dec. 3, 2013