Home
| |
Revised Nov 3: Assignment 5-B - UNIX - Section 040
This assignment is the second half of Assignment 5 for Section 040 - Ian
Allen.
Hand in: The telnet log sheet from the
last Hand In step in hard copy form.
Preparations:
You must understand Chapters 6 and 8 to do this assignment.
Step 1. (Readings in Chapter 6 and Chapter 8)
Use vi to create an answer file named c6+8answers containing answers to the questions
listed in the Week 9 Reading Exercises. Put your name on the first line
of the file. Answer only the following questions:
- Answers to the Chapter 6 Reading Questions 6-5, 6-7, and 6-10.
(For 6-10, type in the
completed table numbered Table 6-2 on p.395)
- Answers to the Chapter 8 Reading Questions 8-7, 8-9, and 8-11 through
8-15.
Make sure that your name is located at the top of the file.
Step 2. (Based on Chapter 8 and Assignment 5-A)
- (New for Nov 3:) Change all occurrences of "ps
-l" to "ps -f"
in the scripts you wrote in Step 3 of Assignment 5. The "-f" option prints the full Unix command
name on ACADAIX. The previous "-l"
option truncates the command name, making it hard to know what the command
names are.
- Redirect the output of each of the four command lines in Item C
of Step 3 of Assignment 5-A into a file named processes. The file must contain the
output of all four command lines. (Make sure you know how to do
this: see Chapter 5 "Adding to an Existing File".) Edit
the resulting output file to remove the output of all of the echo $HOME commands. (Do not remove
anything else.) Save the edited file.
- 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:
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. (The process ID numbers will most likely be
different for your processes when you do this.)
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 last Hand In step of this
assignment.
- Issue the command line:
sort | grep
job | tee bb | wc
and then immediately suspend the entire command line using CTRL-Z (^Z).
(For more explanation on how CTRL-Z works, look up CTRL-Z in 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 suspended command line)
back into the foreground.
(The job in the foreground will now be expecting you to enter input for
the sort command.)
- Type in the following lines for the standard input of the sort command:
I started two jobs and
killed some processes.
Now I must complete the remaining job
and wrap up my assignment.
Press CTRL-D (^D) at the beginning of a line to indicate that you
are finished typing input. The foreground 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 a command to show the permissions and size of just the file named bb created by the command pipeline.
Hand In:
Start telnet logging to record the
following session on your A: diskette. Perform only the following
actions:
- Display your USER environmental
variable.
- Display the date.
- Display the c6+8answers file created
in Step 1.
- Display the edited file processes
created in Step 2.
- Display the file hierarchy
created at the end of Step 2.
- Do the commands listed in Step 3.
- Stop logging and print the telnet log file for handing in.
This one log file is the only thing you should hand in.
|