----------------------- Exercise #3 for CST8129 due September 21, 2005 ----------------------- -Ian! D. Allen - idallen@idallen.ca Remember - knowing how to find out an answer is more important than memorizing the answer. Learn to fish! RTFM! (Read The Fine Manual) Global weight: 2% of your total mark this term Due date: Before the end of your Lab period on Wednesday, September 21. The online deliverables for this exercise are to be submitted online via the T127 Linux Lab using the submit method described in the exercise description, below. No paper; no email; no FTP. Late-submission date: I will accept without penalty online exercises that are submitted late but before 23h00 (11pm) on Thursday, September 22. After that late-submission date, the exercise is worth zero marks. Exercises submitted by the *due date* will be marked online and your marks will be sent to you by email after the late-submission date. This exercise is due before the end of your Lab period on September 21. Exercise Synopsis: Marks: 2% Part I - update your quick-index to common Unix command names. Part II - working with command pipelines. Part III - a small shell script Where to work: Do your Unix command line work on any WT127 workstation. The files you work on will remain in your account after you log off. Do not erase your files after submission; always keep a spare copy of your exercises. WARNING: Do not attempt this exercise on a Windows machine - the text file format is different. You must connect to and work on Unix/Linux. Note that you may connect to a lab workstation *from* a Windows machine (using PuTTY); however, you may not use the Windows machine itself to do your work. Use the vim editor on the Linux machine. Location of the course notes on the Lab workstations: You can find a copy of all the course Notes files on any Lab workstation under directory: ~alleni/public_html/teaching/cst8129/05f/notes/ You can copy files from this directory to your own account for modification or study, if you like. (To avoid plagiarism charges, you must credit any material that you copy and submit unchanged as your own work.) Exercise Preparation: A. Know where to find an online copy of all the course Notes on the Lab workstations. (See above.) You can get a copy of this exercise from the course notes. B. Complete the online Course Notes readings. Any questions? See me in a lab or post questions to the Discussion news group (on the top left of the Course Home Page). C. You may find the argv.sh program (in the Course Notes) useful to tell you how many arguments the shell is passing to a command. The Week 2 notes tell you how to use it. --------------------------------------------- Exercise Details (in the T127 Linux Lab) --------------------------------------------- D. Have you done all the preparation steps? If not, go back and do them. -------------------- Part I - in-lab demo -------------------- Update your text file containing a copy of the notes file unix_command_list.txt. To the right of each of the 15 commands that have been covered in Week 3, write a one-line explanation *in your own words* of what the command does. Show this file to your instructor before the lab ends. (You must use your *own* words in this file.) Ignore all the commands that haven't yet been introduced. You will add to this file next week. -------------------------------------------- Part II - Answer file is exercise03text.txt -------------------------------------------- E. Using VI/VIM, edit a new file named exercise03text.txt on a Lab workstation. The spelling of the file name must be exact, othewise it won't be marked. The spelling must be exact. Exact! F. At the top of the file, create an Exterior Assignment Submission label following the example you will find under the "Assignment Standards" button on my teaching home page (teaching.idallen.com). For full marks, follow the directions for the label exactly. The label has exactly 7 lines, plus an optional Comments line. The spelling of the label fields on the seven lines must be exactly as shown. The spelling must be exact. Exact! G. Preface each of the seven lines of the label with the two characters "# " (octothorpe+space). The lines do not have to be numbered. Leave a blank line below the label. Using vim, read (copy) the following questions from the exercise file into your answer file, below the assignment label. Under each question, write your answers. (These questions are based on last week's lecture and readings in the Course Notes, e.g. glob_patterns.txt, quotes.txt, etc.) 1. Give a command pipeline that will show on the screen only lines five through fifteen (5-15) from the file /etc/passwd. (Hint: You know a command that will show the first fifteen lines, and one that will show you the last eleven of those fifteen lines. Put them together.) 2. Give a command pipeline that will show on the screen only one line from the file /etc/passwd. That one line must be the line from the file that sorts first, alphabetically. Only one line should be output on the screen. ------------------------------- Part III - A small shell script ------------------------------- Create a file named "script3.sh". Put the line "#!/bin/sh -u" (without quotes) at the very top of the file. Make the file executable: $ chmod +x script3.sh Make sure the file executes without errors: $ ./script3.sh (There will be no output from the file yet.) Copy the block of questions 3-15 below into the script3.sh file and add octothorpe comment characters ("#") in front of all the lines. Execute the file and make sure there are no errors and no output. Under each comment, add commands, one by one, that will do the steps below, in order. You must make sure each command works at the command line before you copy it into the the script.sh file and then test it by executing the file. (Hint: Work with two or three shell windows open.) 3. change directories to your home directory 4. remove recursively any directory named "junk3" (Hint: Find an option to have the command ignore nonexistent files so that you don't get an error message if the directory isn't there.) 5. create a new directory named "junk3" in the current directory 6. change directories to make junk3 the current directory 7. show on the screen the name of the current directory 8. put the calendar for July 1954 into a file named "ian_birthday.txt" in the current directory 9. show how much disk file space usage is in the current directory 10. move the birthday calendar output file to the parent directory (the current directory junk3 will now be empty) 11. change directories to the parent directory 12. show on the screen the name of the current directory (this should show your home directory again) 13. show the name of the current host computer 14. show the count of the size in bytes of your current environment (only one number should appear on the screen) 15. display the exact message: It's nice out, when it's not "raining". (Use quoting to make sure all the punctuation appears on the screen.) Execute your file and make sure there are no errors: $ ./script3.sh Copy the completed script file (including all the comments) to the end of your exercise03text.txt answer file for submission. Submission ---------- Submit the finished and labelled exercise03text.txt file for marking using the following Linux command line: $ ~alleni/bin/copy exercise03text.txt This program will copy the selected file to me for marking. You can copy the file more than once. Only the most recent copy will be marked. P.S. Did you spell all the label fields and file names correctly?