1
1
CS3157: Advanced Programming
Lecture #4 Jan 30
Shlomo Hershkop shlomo@cs.columbia.edu
2
Outline
- Feedback
- Homework
- More file handling and reg exp
- CGI
- HTML
- CGI & Perl
- Perl Debugger
- Reading:
– Regular expressions – File handling
CS3157: Advanced Programming Lecture #4 Jan 30 Shlomo Hershkop - - PDF document
CS3157: Advanced Programming Lecture #4 Jan 30 Shlomo Hershkop shlomo@cs.columbia.edu 1 Outline Feedback Homework More file handling and reg exp CGI HTML CGI & Perl Perl Debugger Reading:
1
Shlomo Hershkop shlomo@cs.columbia.edu
2
– Regular expressions – File handling
3
4
5
pcap:x:77:77:ARPWATCH User:/var/arpwatch:/sbin/nologin ident:x:98:98:pident user:/:/bin/false nobody:x:99:99:Nobody:/:/sbin/nologin xfs:x:405:405:X Font Server:/etc/X11/fs:/bin/false mysql:x:6730:1101:mysql server:/var/lib/mysql:/bin/bash
6
7
8
9
10
11
12
13 14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
End User
Server CGI Application
31
– Perl is only a tool here – Don’t memorize, understand
– Don’t be afraid to experiment
– Contents passed to perl script
– Will need HTTP headers before printing
– Depends on server, sometimes just error logs, sometimes error reports on client
32
33
34
#!/usr/local/bin/perl use strict; my $time = localtime; my $remote_id = $ENV{REMOTE_HOST}| $ENV{REMOTE_ADDR}; print "Content-type: text/html\n\n"; print <<END_OF_PRINTING; This is the time : $time <P> and your id is $remote_id END_OF_PRINTING
35
36
– Length of data passed to cgi
– Ip address of client
37
38
39 40
41
Scheme Host Port Path Query Fragment
42
43
44
45
46
47
48
49
50
51
52
53
54
55