| |
Assignment 5-B - UNIX
This assignment is for sections taught by Ian Allen. It is the second half of Assignment 5.
-
Hand in:
- One printed and hand-annotated telnet session log file
in hard copy form. For full marks, follow the Assignment
Submission Standards. In particular, make sure you use Courier
font and annotate your output (see below) before you hand it in.
- Preparations:
- You must complete the work in the previous Chapters (1, 2, 3, 4, 5, 7,
and 13) as well as Chapters 6 and 8 in your Unix text before doing this
assignment.
-
Step 1. (Readings in Chapter 6 and Chapter 8)
Use the vi
text editor to type the answers to the following Chapter Reading/Study
Exercises into the file
named my5Banswers
in your home directory. Number each answer clearly. You will find the Chapter Exercises under the Unix
button on the course page.
Put your name and your Algonquin e-mail address at the top of
the file.
Answer the Chapter 6 Exercises 6-5, 6-7, and
6-10.
(For 6-10, type in the
completed table numbered Table 6-2 on p.395)
Answer the Chapter 8 Exercises 8-7, 8-9, and 8-11 through
8-15.
Put your name and your Algonquin e-mail address at the top of this file.
Number each answer clearly.
Step 2. (Based on Chapter 8 and Assignment 5-A)
Run the scriptC file you created in the previous week's assignment and redirect its
output into a temporary file named processes.
Using the process listings in the file processes,
identify all the processes that were running in a process hierarchy
list, showing which processes were parents of which children. For example, some of your processes might have had the following
relationships in your processes file:
PID PPID COMMAND
12345 92939 ksh
23456 12345 ps
87465 12345 ksh
45678 87465 ps
... etc ...
Create a file called hierarchy and
type in a text diagram that shows the parent and child processes and their
relationships, in the following form:
-ksh (12345)
|----------ps (23456)
|----------ksh (87465)
|------------- ps (45678)
|------------- .....
Parent processes have vertical lines to which child processes are attached
with horizontal lines. We see that parent process ksh(12345) had two
child processes ps(23456) and ksh(87465). Process ksh(87465) itself had
more child processes, of which ps(45678) was one. (The process ID numbers will most likely be
different for your processes when you do this.)
The VI commands "yy"
(copy one line) and "p" (paste the copied line) will be
useful in editing this file.
Step 3. (Based on Chapter 8)
Practice these commands so that you can do them without errors. You
will redo them with logging turned on in the Telnet Log File step of this
assignment. Practice this:
- Enter this four-process command pipeline:
sort | grep
job | tee bb | wc
When you press return, nothing happens. The first command in the
pipeline is expecting input on standard input, which is attached to your
keyboard. Instead of typing input, suspend the entire command line using CTRL-Z (^Z).
(There is more information on CTRL-Z available via the index of
the textbook.)
- Issue the command sleep 900 &
- Issue the command ps
- Issue a command to kill only the wc
process.
- Issue another command to kill only the sleep
process.
- Issue a command to bring the suspended job (the command line
you suspended, above)
back into the foreground. The job in the foreground will now be expecting you to enter input for
the sort command; however, part of
the pipeline has been terminated and it will not work correctly. Press CTRL-D (^D) at the beginning of a line to indicate that you
are finished typing input to the pipeline. The command pipeline should
finish and you should get a shell prompt. (If this doesn't happen,
you have made an error. Break out and repeat the steps.)
- Issue the command line a second time, without killing any processes:
sort | grep
job | tee bb | wc
Type in the following four lines for the standard input of the sort command:
I started two jobs and
killed some processes.
My job is almost done.
Have a nice day.
Press CTRL-D (^D) at the beginning of a line to indicate that you
are finished typing input. The command pipeline should
finish and you should see the output from the last process in the pipeline
followed by a shell prompt. (If this doesn't happen,
you have made an error. Break out and repeat the steps.)
- Issue a command to show the permissions and size of the file named bb created by the four-process command pipeline.
Step 4. (Creating the Telnet Log File)
You need to have done all the readings, completed all the prerequisite
Chapters, and completed all previous steps of this Assignment to do this
logging Step.
Login to Unix and then
turn on telnet logging to record
the following Unix session on your A:
diskette or on your N: drive. When asked to display the
contents a file or script, use the cat
command. (For full marks, do not use an editor or any commands that paginate the file,
since the pagination mis-formats the display of the file in the log.) Perform the following actions for
the log file:
- Set your shell prompt to be your Algonquin userid. (You reviewed
creating a Personalized Shell Prompt in Chapter 5.)
- Display the contents of your USER environment
variable.
- Display the current date.
- Display the contents of the my5Banswers file created
in Step 1.
- Display the contents of the edited file processes
created in Step 2.
- Display the contents of the file hierarchy
created at the end of Step 2.
- Do the commands listed in Step 3. (Highlight each command
name when you annotate your output listing.)
- Display the current date.
Turn off telnet logging. Print the Telnet log file using a
monospace (Courier) font. Choose the font size so that the contents of
your answer file looks neat and prints without line wrapping.
Step 5. (Annotating the Telnet Log File)
Annotate your printed Telnet log file output by hand as follows:
- Take a pen or marker and draw long, page-width lines between each of
the numbered actions you performed in the previous step.
- Write in (using pen or marker) the number of the action beside each
of the actions. Use the action numbers given in the previous
step.
- Highlight or underline each of the Unix command lines
you typed to the shell to do the actions in the previous step. Do not
highlight the output of the command lines. Highlight
only the Unix command lines that you typed in.
There is only one telnet session log file to hand in. It comes
from the Telnet Log File step. Do not log or hand in anything else other than the one log
file from the Telnet Log File step. Make sure you annotate the log file by hand as required in
the Annotating step.
|