======================= CST8129 Lab Exercise #4 (Week 6) ======================= -IAN! idallen@ncf.ca Due: 08:00 (8am) Saturday October 5, 2002 Marks: 2% Purpose: - review some of the work done so far (Chapter 8 and 9) Hand in format: online submission only - no paper, no diskettes Exercise (Instructions): 1. Do Chapter 9 Lab 1 - First Script - p.483. with modifications: In step "a." also include your full Assignment Submission label. In step "l." replace the word "me" with a shell variable containing your login userid. All variables must be properly quoted. In step "f.", replace "cat /etc/motd" with "head -1 /etc/issue". 2. Edit the script file and, in front of each command line that you used in sections "b." through "m.", write exactly one line of comment. The comment will be an explanation of one option that you might use with the command name on the following command line. Pick the option you comment at random from the list given in the "man" page for that command. For example, the "head" command has 4 options (plus --help and --version). I pick a random number (roll a 4-sided die?) and decide to pick the 3rd option, which is "-q". I write this single comment line in front of my use of "head" in step "f.": # Step f: option -q (quiet) means don't print file names head -1 /etc/issue Put the step letter as the first part of the comment line that you add, as you see above. Do this for each command that you use in sections "b." through "m.". Don't repeat any comments; pick news ones. (The comment is random; it will not necessarily be an option that you actually use in the following command line.) 3. Change the permissions on this script file to "read-write-execute-only" for you, "read-only" permissions for group, no permissions for other people. 4. In the Linux lab, copy your script to this location: ~alleni/cst8129/02f/lab04exercise/xxxxnnnn.sh where xxxxnnnn is your Algonquin userid (e.g. abcd0001). Files with the wrong name or wrong Unix permissions will be penalized. Your exercise is due online before the date and time given above. Late penalty for this assignment: 50% per day ------------------------------ Chapter 9 midterm preparation: ------------------------------ Also complete the following this week. (This is not for hand in yet.) Learn the traditional "test" operation; skip over the sections that work only in Bash 2.x. *. Review parameters and arguments in Chapter 9 (section 9.4). Make sure you actually *do* and *understand* the examples shown! *. Review the "exit" command in Chapter 9 (section 9.5.1). Make sure you actually *do* and *understand* the examples shown! *. Study the "test" command (and its single-square-bracket equivalent) in Chapter 9 (section 9.5.2). Fix the text examples - quote all the variables! Skip over the "Bash 2.x" examples that use double parentheses (()) and double brackets [[]]. In Table 9.3 (p.406), know how to use everything except "Compound Test" (it works in Bash 2.x only). In Table 9.4, learn the traditional operators and skip over the Bash 2.x operators. *. Study the "IF/ELSE/ELIF" statement in Chapter 9 (section 9.5.2/9.5.3/9.5.4/9.5.5.) Concentrate on the "old format" in the examples (the format that uses single square brackets [], not double sets of parentheses (()) or double sets of brackets [[]]). Skip over the "new format (Bash 2.x)" examples on first reading. *. Type in and convert the script 9.21 (p.411) to use traditional format test expressions (single square brackets), not Bash 2.x expressions. Fix this script - all variables must be properly quoted. *. Type in and convert the script 9.24 (p.414) to use traditional format test expressions (single square brackets), not Bash 2.x expressions. Fix this script - all variables must be properly quoted. *. Type in the script at the top of Example 9.25 on p.416. Fix this script - all variables must be properly quoted.