======================= CST8129 Lab Exercise #7 (Week 9) ======================= -IAN! idallen@ncf.ca Due: demo script in lab period only - no hand in Marks: 2% Late penalty: 100% after last lab on Friday this week. Purpose: - review some of the work done so far (Chapter 8 and 9) Demo procedure: When you are ready to demonstrate your script, put your name on the board at the front of the room under the column "first demo; section 01x". Demonstrate the following three inputs: 1 s 4 with the output of your script redirected to file "out". If there is time, I will see re-demos of the same script. Put your name on the board under "second demo". (Note: There may not be time for a second demo.) Priority is given to people who are registered in a given lab section. If you are trying to give a demo in a section that is not your registered lab section, you must wait until after all the registered students have done their demos and have had their questions answered. Put your name on the board under "other sections demo". -------------------------------------------------------------------------- TODO: Modify Example 9.31 on p.424. *) Type in Example 9.31 on p.424. Name the example "termit". Add the usual #!/bin/bash -u line to the top of the script. Execute it using ./termit and make sure it echoes the correct output. *) Move the duplicated code out of each case to the bottom of the "case" statement. Less code is better code. *) Move the prompt "Select a terminal type:" to the bottom of the menu displayed to the user and suppress the newline usually generated by the "echo" command (RTFM). *) Fix the menu and the prompt so that they display on standard error, not standard output. (Prompts, menus, and error messages should always be sent to display on stdandard error.) *) Add a default case (asterisk) to the script that echoes the line "SSSS: TERM is unchanged from value 'XXXX'" on standard error, where SSSS is the name of the script and XXXX is the current value of the TERM variable. Use the exact punctuation given. Then exit the script with a non-zero return code. For example: $ ./termit 1) linux 2) xterm 3) sun Select a terminal type: junk ./termit: TERM is unchanged from value 'eterm' $ echo $? 2 *) For each case, modify the case pattern so that the case also accepts the first letter of each associated terminal type as well as a digit. For example: $ ./termit 1) linux 2) xterm 3) sun Select a terminal type: s TERM is sun. Demonstrate your script before the Lab period ends.