CS 1206: Assignment 6

Due Friday, April 16, 1999 by 5pm

100 Points




Writing A Shell Script

Your assignment is to write a simple shell script called whereami. When invoked, this script will print out the user name of the current user, the name of the current machine, the full path name of the current working directory, the current time, and a listing of the contents of the current directory. This is followed by a blank line, then a count of the number of ordinary files, executable files, directories, and links in the current directory. Output from whereami should follow this example:

You are          : ltw
You are on       : cayuga.cs.vt.edu
Current directory: /f/ltw/classes
The time is      : Fri Oct 31 10:21:16 EST 1997
Current directory contents:
1206-old/       bin/            invd2.dat       skel/           working/
A5.html         configs/        invd3.dat       sum3/           zlink@
Bugs.txt        gnuemacs-lib/   invd4.dat       tools
Mail/           invd1.dat       nsmail/         whereami*

7 ordinary,  1 executable,  9 directories,  1 links.

Remember that your shell script must start with a proper "bang line":

    #!/bin/ksh
It should also end with a proper return statement. Your shell script will be graded on a DEC Alpha running Digital UNIX, so you should write your script such that it runs correctly under both FreeBSD and Digital UNIX. You can test your script on any of the DEC Alphas (doberman, malamute, rottweiler, boxer, husky) in the lab. Note also that for obvious security reasons, your script will be graded within a restricted shell (rksh), where certain operations are forbidden. Thus your script must run under FreeBSD, Digital UNIX, and rksh.

Sources For Information

Your shell script is free to access any shell or environment variables, and call any commands provided on the system. Some shell variables you might wish to explore include:

Some commands that may also be of use are (see their respective manual pages):

Part III: Submitting Your Answers

You are to hand in your assignment by using the Automated Grader application. To receive credit, your assignment must be submitted before the time and date listed above. It is your responsibility to successfully submit your assignment via the Automated Grader. A maximum of three submissions are allowed per student. Your submission must be a plain ASCII text file in exactly the format defined below. Do not insert any extra notes or explanations.

Your submission must be plain ASCII text that contains the following:

Brief instructions are given below on how to use the Grader, but it will be helpful to visit the Automated Grader's web page.

After connecting to the Internet, run the Grader program with the command:

Acceptor_UI

A dialog box will then appear. If the title of the dialog box says "CS 1206 Grader Client" then you have the correct application; otherwise you are running the wrong client application on your local machine. Fill in your original PID, e-mail password, and Student ID. Click inside the Course Index field and select the lab section you are enrolled in. Type in HW6 for the Project Number. Enter the full path of the file to be submitted, or click on Browse to find it. After all the information is typed in, click on Submit. If your submission was successful, a window will appear stating "Your file has been submitted. A confirmation will be sent to you via e-mail." If your submission did not succeed, then a dialog box will appear describing the problem. Correct the information and resubmit. If the submission was successful, click the Quit button. After a few minutes (or sometimes hours!), you should receive an e-mail message verifying the file was received.

Also, remember that no late assignments are accepted.




Layne T. Watson <ltw@cs.vt.edu>
Last modified: Wed Mar 31 09:46:17 EST 1999