Assignment 2

Background

The UNIX operating system provides a command called finger which displays information about users logged onto a system. For example, typing finger by itself displays in multi-column format information about all users logged onto a system. Typing finger followed by a user name gives more detailed information about the user, whether or not the user is logged in. You can also specify a machine name (preceded by an @), and finger will retrieve information from the specified machine. However, many systems filter or block outside finger requests.

The format of a finger query is precisely defined, but the format of the response may vary. The finger protocol is described in detail in RFC 1288. You can find out how to use finger by typing the command

man finger

Experiment with the finger command to display login information and to obtain information about some of your friends.

Assignment

The finger program seems complicated, but actually it is quite simple. All it does is establish a TCP connection to a host on port 79. Once the connection is established, finger sends the user names for which information is desired, waits for a response from the host, and displays the output.

Write a Java program Finger.java that mimicks the functions of the UNIX finger program. Your program should take up to one argument on the command line and perform the following actions:

  Command Line |
    Argument   |                           Action
 --------------|------------------------------------------------------------------
    none       | Display the users logged onto the local host
    user       | Display information for the specified user from the local host
    user@host  | Display information for the specified user on the specified host
    @host      | Display the users logged onto the specified host
Your program should simply print to the screen whatever information is sent to it by the finger server. Be sure to include error handling. That is, if a user uses your program incorrectly or specifies an invalid machine name, your program should print appropriate error messages.

Groundrules

See the rules for programming assignments on the main course Webpage. You may work individually or in teams of two or three people.

Submission

As noted on the main course Webpage, assignments are to be submitted electronically as e-mail attachments. Use the address

contst10@cs.gettysburg.edu

The e-mail message itself must contain the Honor Pledge and the full names of the people submitting the assignment. Only one submission should be made for each team.

Due Date and Time

This assignment is due at 12:01 AM on Wednesday, February 7. Once again, late work is not accepted.