Homework 4: Fun with shell variables!

Due Monday, February 12, by 10:30 AM

A program has been placed in /opt/cs228 named check_vars. It will verify your solutions to questions 1, 3, 4, and 5. This program is written in Python, and if you are curious what it looks like, you can examine it with cat, less, a text editor, etc.

As usual, place the commands you used to solve each of the 5 problems into a file called homework4. This time, suggestions for commands aren't given, for all questions, but a combination of export, grep, and tail should suffice.
  1. Add location of check_vars to PATH. The location is /opt/cs228. After this, you should be able to run check_vars.py without specifiying the path.
  2. Besides being used to set variables, the export command can print out a list of all variables defined for your shell session. Write a command which will print out all the variables which contain your username
  3. Set a variable named ANIMAL to the word giraffe. Remember to spell the word right! Then run check_vars.py, and if your variable is set correctly, the program will let you know.
  4. Place the secret code gerbil in a file, and set the variable CODEFILE to the path to this file. Run check_vars.py, and it will indicate if this is correct.
  5. Set the variable INDCMD to a command that prints the last line of /var/www/index.html. I recommend using tail for this purpose. Set the variable, and then run check_vars.py to see if it is correct.
Turn in your homework by creating a file named "homework4" with no extension in your home directory, with permissions set so that only you can view the file. This assignment is worth 35 points, 5 from correct naming, 5 from correct permissions, and 5 from each of the problems above.