CSCI A348/548
Take-Home Quiz Three

Fall 2000


Due date
October 18, 11:59pm.
Late policy
Please try to turn things in on time, it will help you with the midterm.
Work policy
Working in groups is encouraged but please turn in your own version of the assignment.
Task
A number of questions will be posted here. You will need to recreate the document on your web site, under protected and include answers to all the questions for our review.
Grading
Feedback will be provided within a week, grades will be posted on-line.
Graduate standing
Undergraduates are responsible for just 2/3 of the questions below, grad students for all of them.


These are the questions:

  1. What is tar? When do you use it and why?

  2. What is crontab? When do you use it?

  3. Write the absolute path of your server's root.

  4. Write the absolute path of your server's document root.

  5. How do you find out if your server is running, from the Unix prompt?

  6. Which .conf files did you have to edit before installing Apache.

  7. Give an approximate list of settings that you had to edit when installing Apache.

  8. How do you start your server if it's not running?

  9. How do you re-start your server if it's running?

  10. What's in the httpd.pid file?

  11. When might you need to use what's in the httpd.pid file?

  12. How do you password-protect a directory? (Just the basic ideas, not details).

  13. Here's a file:
    -rw--w--wx   1 dgerman       422 Oct 14 17:16 gamma.html
    How was chmod used to change the permissions on this file as shown?

  14. What is GET? What is POST? When are they used? How are they different?

  15. Here's a simplified version of the circular script. Does it work? Explain.
    #!/usr/bin/perl
    
    &ReadParse; 
    
    &header("Lab 5 Circular Script");
    
    &printform($in{count}); 
    
    &trailer; 
    
    sub printform {
        local ($arg) = @_;
        local $count = $arg + 1;
        print qq {
          <form method="POST" action="$ENV{SCRIPT_NAME}"> 
              Your call has number: <font size=+5>$count<font>. <p>  
              Press <input type="submit" value="here"> to call again. 
              <input type="hidden" name="count" value="$count"> 
          </form>
        }; 
    } 
            
    sub header {
        local ($t) = @_;
        print "Content-type: text/html\n\n<html><head>";
        print "<title>$t</title></head><body bgcolor=white>\n";
    }
            
    sub trailer {
        print "\n</body></html>";
    }
            
    sub ReadParse {
            
        if ($ENV{'REQUEST_METHOD'} eq 'GET' ) {
    	$in = $ENV{'QUERY_STRING'};
        } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
    	read (STDIN, $in, $ENV{'CONTENT_LENGTH'});
        }
            
        @in = split(/&/, $in);
            
        for ($i = 0; $i <= $#in; $i++) {
    	$in[$i] =~ s/\+/ /g;
            ($key, $val) = split(/=/, $in[$i]); 
            $key =~ s/%(..)/chr(hex($1))/ge; 
            $val =~ s/%(..)/chr(hex($1))/ge;     
    	$in{$key} = $val;
        }
    }
    
  16. You are testing a CGI script and when you load it in the browser you get an error message, but the message is very general and doesn't tell you anything about your program. Describe at least two different ways of finding out what went wrong.

  17. Write the HTML for a form like this:
    Username
    Password

    Note: the form contains a text field and password field inside a 2x2 table. Call the two fields uname and pword respectively. Make the form POST the data to the following script:
    http://burrowww.cs.indiana.edu:10000/cgi-bin/simpleCheck
  18. Keeping in mind what Perl considers as true and false specify the output for each of the following two Perl programs: The first program is shown below:
    #!/usr/bin/perl
    $i = 0; $j = 1;
    if ($i = 2) { print $i; }
    else { print $j; } 
    

  19. Same program as above with only $i = 0 in the condition for the if statement.
    #!/usr/bin/perl
    $i = 0; $j = 1;
    if ($i = 0) { print $i; }
    else { print $j; } 
    
  20. Suppose that you still have the default (initial) setting in your httpd.conf file as:
    User nobody
    and a script script in your cgi-bin directory that looks like this:
    -rwx------   1 username  students     192 Sep 15 01:32 script
    where username is your username. Assume script has the following code:
    #!/usr/bin/perl
    print "Content-type: text/html\n\nHello world!"; 
    
    What will happen when you call this script with a web browser? Why?

  21. Assume this crontab entry:
    * 6 * * * /u/username/bin/starthttpd 
    
    and a properly configured starthttpd.

    Then your server will be checked and if needed restarted exactly how many times a day?

  22. Consider the following JS code:
    function Globe() {
      this.x = 3;
      this.y = 3;
    }
    g = new Globe();
    g["x"] += g.x; 
    document.write(g.x);
    What will the browser display when you load this page in it?

  23. Explain this diagram:

    Where have we seen it, how do we use it?

  24. What's dynamic HTML?

  25. How are CGI scripts different from regular programs?

  26. What's ENV? How do we use it?

  27. What's an event handler, and where did we see any?

  28. What's HTTP?

  29. What's CGI?

  30. What's grep and when do you use it?


Last updated: October 14, 2000 by Adrian German for A348/A548