Assignment 6

Back Up Next

horizontal rule

Home
Assignment 1
Assignment 2
Assignment 3
Assignment 4
Assignment 5
Assignment 6
Assignment 7

 

 

 

Assignment 6   100 pts

Your last assignment #7 will be a shell script similar to this week's assignment. The difference is that you will need to implement several protection features and much more detail on the menu options that will be used on this assignment.

Control structures, loops and a menu system is part of any high level programming language. It allows the program to branch out to different parts depending on a logical decisions. Remember that binary systems have only one outcome (true (1) or false (0))

You will develop a shell script with the case command selecting the following unix commands. Please look at your book (page 444). The script command_menu. Your job will be to implement similar program but have a total of 10 commands, plus the *) catch all.

bullet

This program will have a menu with 10 commands. Use the commands from the menu below (the implementation is similar to the command_menu script on page 444).

bullet

Your menu will be surrounded by a loop, either the until or while loop, so that when one option is concluded it will go back to the main menu until the user selects an option x to exit. Try NOT TO USE THE EXIT command to quit the script, use the proper logic of the loop control to exit the program. Also using while : or while true or until true, etc. is not a good loop logic. You have a menu so, the exit should be an option in the menu such as, when option <> q, etc.

bullet

Your first option will be an emailer program. This emailer program will be the automated process of what we had done:  mail -s "......" (The whole program should be in one file, do not call different sections of the the program by using ~/emailer.sh for instance. It will not work for me since I will not have this file called emailer.sh when you submit me the assignment. So, enter the whole program in one file)

bullet

THIS TIME Email this assignment to wmorales on the linux system since I will have to run your script. Use the command mail -s "cs140U online - Your Name - Assignment 6" wmorales < menu_script.sh

bullet

 Place a copy in the assignment dropbox. Before uploading the script  menu_script.sh, make a backup copy, rename it in the linux and call it menu_script.sh.txt, convert it to DOS format using the command unix2dos, then transfer it to your computer using psftp or filezilla, then upload it. Do the same for assignment #7.  

bulletMake sure to use proper documentation (comments) on your program and ask questions if you are in doubt about what need to be accomplished and use the discussion board.
bulletA comment block such as those on the examples seen in the lecture must be on top of your script file with your name, date, description of the program. Make sure to document your program with comments in the various areas of your program.
bullet

Use proper Program Style

bullet

Menu example:

bullet

wmorales@syccuxfs01:~> bash menu_script.sh
Command Menu

a. Emailer Program
b. Users Currently Logged On
c. Current Date and Time
d. This months Calendar
e. name of the Working Directory
f. Contents of the Working Directory
g. Find the IP of a Web Address
h. See your Fortune
i. Print a file (on the screen)
j. Exit

Please select a letter:

bullet

Here is samples interaction with the emailer portion of the program. There is no need to display the calendar or show a list of available files to attach.

bullet

Please select a letter: a (this would go to the option for the emailer program that you created)

Welcome wmorales

Today is: Sat Feb 26 16:23:51 PST 2005

This is this months Calendar:

February 2005
Su Mo Tu We Th Fr Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28


This program will allow you to send a message,
with a file attachment, to any selected user.

Please enter the subject of your message and press <enter>: Test message

Please enter the email address of the recipient and hit <enter>:wmorales@pcc.edu

Please enter the file to be attached to this message and press <enter>.

please choose a file: testfile

bullet

Then it would got back to the main menu

Assignment 6 explained (You will need quicktime to play this video)

Assignment 6 video explanation


Some items to check where points may be deducted, the same will apply for #7 with additional items to be checked as required in the assignment instructions.

 =============

1) Lack of comments on your program

2) Use of meaningful variable names

3)  #!/bin/bash  should be the first line of our program.

4) Using the option read -n1 varname allows you to tap on �one key to continue�

5)  Many commands might produce a full screen of output and you will not be able to see the what was on the top, always  | more

6) Use the command clear to clear the screen and have a non-cluttered output. =======================

7) Use the logic of the loop to get out of the loop, using exit 1 or exit 0 still terminates the program but you are forcing the end of the program instead of using the logic of a loop

8) There are many ways to implement the until loop, but you need to make sure to use the proper operator and initialize the variable before it is checked in the until loop. Otherwise the comparison condition may always be true or false. Same not as above, use the logic of the loop to end it.

9) Consider using functions.  They will be easier to troubleshoot if your program does not work and it organizes your program

10) Initialize your variables to a value.

11)  Test you emailer.

12) Binary logic. Remember that when you do binary logic you are always comparing two items. For instance  if a > b then .. you do not use  if a > b > c, you need to break it down into if a > b and a > c

 

 

 

horizontal rule

Back to CS140U Homepage
This page was last modified September 26, 2004
wmorales@pcc.edu