OPS435: Assignment #2

HAND-IN REQUIREMENTS:

Description

Due Date

Submit shell script that meets requirements for assignment #2 (use sample runs for reference and input/output requirements). This shell script is run without arguments. When run, this shell script will allow the user to store purchase and payment information for customers.

Friday December 2, 2011 @ 11:59:59 PM



OVERVIEW / REQUIREMENTS:

You are the webpage administrator for this company, but while you are away, your boss may need to post simple webpages. You are looking foward to going on a vacation to Europe for four weeks.The only problem is that your boss is “completely useless” when it comes to creating webpages, and has become totally dependent on you for webpage creation. You have decided to create a shell script called buildHtml.bash that will automate the process to create, view, publish and remove simple webpages. In this way, your boss is still dependent on you in order to create more complex webpages when you return from your vacation...


Your shell script will not take any arguments, and you do NOT have to error-check for the number of arguments after your shell script...


When run, your shell script will download two files that will provide valid color names and valid tag names (simple non-empty tags) that are permitted when building a webpage. You will use the wget command (with the -q option to suppress output) to download these two files. You can assume it is OK to download those files in the current directory where this shell script is run. The wget command uses the URL of the file to download.


Here are two valid URLs that contain both valid color names and tag names:



Then, your shell script will present the user with a menu, to either create a simple webpage, view the created webpage's HTML code, publish a webpage to the ~/public_html directory, remove the webpage, or exit the shell script. If the user presses <CTRL><c>, the screen will clear, a standard output message (NOT stderr) message will indicate that the program will be terminated, all temporary files will be removed, and the shell script will terminate with a false value... (refer to stample runs)...


The menu system should continue to loop until the user enters one of the valid numbers (1, 2, 3, 4 or 5). The screen will clear prior to menu being displayed. After the user makes and completes the menu item, the script will wait until the user presses the ENTER key, then the screen will clear, and the menu will be displayed...


Below is a description of what each menu item does:


Create Webpage


This section will build an html webpage. Your shell script will prompt for the following information:




At this point, your shell script should build a webpage in this format:

<html>

<head>

<title>Webpage Title text you entered...</title>

</head>

<body style="background-color:Background Color you entered;color:Text Color you entered">


Then your webpage will prompt for the number of tags to enter. For your shell script, you are only using non-empty tags (i.e. Tags in the format: <tag> text </tag>).

If the number of tags entered is less than 1, then you continue looping until the user gets it right!


Then, using a loop your shell script asks for the following information:



Your webpage will take this information and add these tags to your webpage, and after all tags have been created, you will end the webpage with:

</body>

</html>


This webpage should be saved as a temporary file, in case the user wants to publish this webpage...


The shell script will then wait until the user press <ENTER> to continue...(Refer to next menu item)...


NOTE: If the user decides to select Create Webpage, then previous webpage saved as a temporary file will be overwritten... Refer to the Sample Run.



View Webpage


The shell script will view the contents of the temporary file (prior to publishing to the Internet). Your shell script will wait until the user press <ENTER> to continue...


Refer to the Sample Run.


Publish Webpage


The shell script will then prompt the user if they want to publish their webpage (having viewed the created webpage by the web-browser). If the user enters a lowercase or uppercase “y”, the shell script will ask for a filename (use the .html extention), and then the temporary webpage file will be copied to the user's public_html directory (eg. ~/public_html) using that webpage name. A standard output message should inform that user that “the webpage has been published...”. If the user enters anything else, then the stdout message should inform the user that the webpage was NOT published... Your shell script will wait until the user press <ENTER> to continue...


Refer to the Sample Run.


Remove Webpage


The shell script will prompt the user for the name of the webpage file to remove (use the .html extension). You can assume you just type the filename since the file will reside in the ~/public_html directory. If the file exists, then the script will ask the user if they want to remove that webpage file. If the user presses “y”, then the webpage is removed from the ~/public_html directory... A message should indicate whether or not the webpage has been removed. Your shell script will wait until the user press <ENTER> to continue...


Refer to the Sample Run.



Exit


When selected, the shell script will clear the screen and exit with a true value....


Sample Runs (Linux commands, shell script, or comments in bold)

./buildHtml.bash
# <-- screen clears ...
WEBPAGE BUILDER MENU

1. Create Webpage
2. View HTML code
3. Publish Webpage
4. Remove Webpage
5. Exit

Please Make a selection >> 1
Please enter a webpage Title: This is my webpage Title...
Please enter text color: yello
Invalid text color. Please re-try: yellow
Please enter background color: blue
How many tags to enter: e
Invalid number. Please re-enter: 2
Please enter a tag name: This is my paragraph...
Invalid tag. Please re-enter: p
Please enter text (press <ENTER> to finish): This is my paragraph
Please enter a tag name: block
Invalid tag. Please re-enter: blockquote
Please enter text (press <ENTER> to finish): This is my blockquote

Webpage created...

Press <ENTER> to continue
# <-- screen clears when user presses ENTER ...
WEBPAGE BUILDER MENU

1. Create Webpage
2. View HTML code
3. Publish Webpage
4. Remove Webpage
5. Exit

Please Make a selection >> 2

Here is HTML code:

<html>
<head>
<title>This is my webpage Title...</title>
</head>
<body style="background-color:blue;color:yellow">
<p>
This is my paragraph
</p>
<blockquote>
This is my blockquote
</blockquote>
</body>
</html>

Press <ENTER> to continue...
# <-- screen clears when user presses ENTER ...
WEBPAGE BUILDER MENU

1. Create Webpage
2. View HTML code
3. Publish Webpage
4. Remove Webpage
5. Exit

Please Make a selection >> 3

Do wish to publish to your public_html directory? (y|n)y
Please enter name of webpage to publish: me.html

Webpage published...

Press <ENTER> to continue
# <-- screen clears when user presses ENTER ...
WEBPAGE BUILDER MENU

1. Create Webpage
2. View HTML code
3. Publish Webpage
4. Remove Webpage
5. Exit

Please Make a selection >> 4

Please enter a webpage filename to remove (eg. filename.html): me.html
Do you wish to delete "me.html"? (y|n)y

Webpage deleted...

Press <ENTER> to continue
# <-- screen clears when user presses ENTER ...
WEBPAGE BUILDER MENU

1. Create Webpage
2. View HTML code
3. Publish Webpage
4. Remove Webpage
5. Exit

Please Make a selection >> u
Invalid selection. Please re-enter: 5

./buildHtml.bash
# <-- screen clears ...
WEBPAGE BUILDER MENU

1. Create Webpage
2. View HTML code
3. Publish Webpage
4. Remove Webpage
5. Exit

Please Make a selection >> # <== User presses <CTRL><c>

# <-- screen clears ...

Program has been terminated.
Press <ENTER> to exit...

# End of Sample Runs...



SUBMISSION INSTRUCTIONS:

You will run a shell script that your instructor created. When this shell script becomes available, students will run this script to submit their assignment #2. The Assignment will NOT be excepted by the instructor for marking if it is not submitted by the submission shell script - no exceptions...

When available, the pathname of the submission shell script will be displayed in the table below...

Submission Instructions

Link to assignment #2 submission instructions: [ html ]


GRADING EXPECTATIONS

  1. Your assignment #2 shell script is to be submitted from your Matrix account by the submission program displayed above – no exceptions.

  2. Your shell script will be evaluated based on the following general criteria:

  3. If your script is not functional when tested, or produces too many incorrect answers, it will receive a mark of zero and must be resubmitted with in 7 days. Once resubmitted, such assignments can receive a maximum of 55%.

  4. Late assignments will carry a penalty of 10% per day, since assignment is submitted electronically (i.e. weekends count!).

  5. Every assignment will be checked for plagiarism. If any copying is discovered, both students will receive a mark of 0
    and a Dishonesty report will be entered in both student's files.

Good Luck :)