IT 244: Introduction to Linux/Unix
Homework 8
Due Sunday, April 01st 11:59 PM
All this work should be done on users3.cs.umb.edu
Deliverables
-
A shell script named hw8.sh that performs the operations listed below.
This file should be in an hw8 directory inside your
hw directory inside your it244 directory.
100 points
Requirements
- Create an hw8 directory in your hw directory
inside your it244 directory
- Go to the hw8 directory and run Unix commands that will execute the steps below
- When you have a command line that does what the step asks you to do, paste it into
hw8.sh using
nano
or any other text editor
- When you have completed all the steps, create an
echo
statement before the commands
for each step, that will print the step number to the terminal
Testing
- The script hw8.sh must have the format specified in
this document
- Scripts that do not follow the rules specified in the document mentioned above will
will have points deducted from their score
- Be sure to test your script and correct any errors you find
- You will lose 5 points for each error that occurs when running your script
- To run your script and see only the error messages run the following command
./hw8.sh > /dev/null
Steps for Script
-
Perform the following actions
- Run
ls
on a file that does not exist
- Run
ls
on the same file, but redirect Standard Error to
/dev/null
- Run
ls
on the same file, but redirect Standard Error to
errors.txt
- Print errors.txt to the terminal
Run one command for each of the items above.
-
Using 3 commands on the same command line
- Go to your home directory
- Run
ls
- Return to your hw8 directory
-
Copy bother10.sh from /home/tsoro/course_files/it244_files
to your hw8 directory.
Write a single command line that
- Runs bother10.sh in the background sending the output to /dev/null
- Runs bother10.sh in the background sending the output to /dev/null
- Runs bother10.sh in the background sending the output to /dev/null
- Runs
ps
in the foreground
-
Using the directory stack mechanism do the following
- Go to your home directory
- Show your position in the filesystem
- Go to my home directory
- Show your position in the filesystem
- Return to your home directory
- Show your position in the filesystem
- Return to you hw8 directory
- Show your position in the filesystem
-
Do the following
- Create the local variable foo and assign it the value "FOO"
- Create the global variable bar and assign it the value "BAR"
- Write a single command that will print the values of foo and bar
-
Do the following
- Copy print_foo_bar.sh from
/home/tsoro/course_files/it244_files
to your hw8 directory
- Run print_foo_bar.sh
The value of foo will not print because it is local to the
login shell and cannot be seen in a subshell.
-
Do the following
- Create the global variable my_city
and assign it the name of the town you live in
- Write an
echo
statement that uses my_city
to tell me where you live.
The entire statement must be quoted.
-
Print the value of the keyword shell variable whose value is a list of all the directories Bash will search to find an executable file with the
same name as the command you typed on the command line.
-
Print the value of the keyword shell variable whose value is the absolute pathname of your default shell.
-
Run a command that will show you all your global variables.