]> scripts.mit.edu Git - www/raw.git/blob - faq/46.mdwn
Import from TextPattern
[www/raw.git] / faq / 46.mdwn
1 [[!meta title="Can I use scripts.mit.edu to generate an Apache-style log file for my web.mit.edu site?"]]
2 Yes. The combination of Server Side Includes on `web.mit.edu`, a
3 Perl script, and the SIPB web script service allows you to get a
4 log file similar to the data you would be able to get if you were
5 hosting the web pages on your own server.
6
7 How to set it up:
8
9 \1. [Sign up to use scripts.mit.edu](/web).   
10  2. Save the
11  [fake\_log.pl](http://web.mit.edu/scripts/www/fake_log.pl.txt)
12  script into your `~/web_scripts` directory with a name that ends in
13  `.pl`.  
14  3. Make sure your web pages have the extension `.shtml`, and insert
15  the following code into your web pages, replacing `USERNAME` with
16  your username (and, if you called `fake_log.pl` something else, use
17  the name that you chose):
18
19     <!-- Generate data that looks like an Apache log -->
20     <img src="http://scripts.mit.edu/~USERNAME/fake_log.pl?uri=
21     <!--#echo var="DOCUMENT_URI" -->&amp;ref=
22     <!--#echo var="HTTP_REFERER" -->&amp;met=
23     <!--#echo var="REQUEST_METHOD" -->&amp;pro=
24     <!--#echo var="SERVER_PROTOCOL" -->" 
25     width="1" height="1" alt="fake image for tracking"/>
26
27 \4. The `fake_log.pl` script logs each hit to a file called
28  `fake.log` in your `~/web_scripts` directory. This log is designed
29  to be compatible with Apache log files, so that you can use any of
30  the myriad tools for analyzing and visualizing data from Apache log
31  files.
32
33 Some questions and answers:
34
35 **How does this work?**
36
37 The `fake_log.pl` script works by taking the data returned from
38 several Server Side Includes that work on `web.mit.edu` and using
39 that and other data to write out an entry with the same format that
40 Apache uses.
41
42 **Since you’re just feeding information into a Perl script instead of getting the real server logs, couldn’t someone feed the Perl script garbage, or misleading information?**
43
44 Yes. Invalid information will probably make the Perl script just
45 plain fail. This method of logging data does not prevent people
46 from deliberately feeding you bad data, but in most cases, no one
47 will care to take the time to do so.
48
49 **Will this log hits from text-only browsers?**  
50 Since this tracking method relies on the browser loading images,
51 this will not log hits from text-only browsers.
52
53
54