# COMP-325 Assignment 2 - mo khan (3431709) > Write shell scripts specified in problem 6 at the end of Chapter 16. > Write shell scripts specified in problem 7 at the end of Chapter 16. > shell scripts specified in problem 13 at the end of Chapter 16. I have placed the Bourne shell scripts in the `bin` directory. I have also included tests for these scripts in the `test` directory. I have bundled a copy of [bats](https://github.com/sstephenson/bats) to make it easier to run the tests. ```bash $ sh ./bin/test 1..10 ok 1 testing ok 2 invoke with a single integer ok 3 invoke with multiple integers ok 4 invoke with single non-numeric ok 5 invoke with multiple non-numeric ok 6 invoke with mixed numeric and non-numeric ok 7 invoke with a host on the network ok 8 invoke with a host not on the network ok 9 invoke without a hostname argument ok 10 invoke with multiple hostnames ``` All source code related to this assigment is stored in a private git repository hosted on GitHub. Access is available upon request. ## Chapter 16 ### Problem 6 Write a Bourne shell script that takes a list of integers as the command line argument and displays a list of their squares and the sum of the numbers in the list of squares. ```bash $ sh bin/problem-6.sh 1 2 3 4 5 squares: 1 4 9 16 25 sum: 15 ``` ### Problem 7 Write a Bourne shell script that takes a machine name as an argument and displays a message informing you whether the host is on the local network. ```bash $ sh bin/problem-7.sh localhost localhost is on the network $ sh bin/problem-7.sh invalid invalid is NOT on the network ``` ### Problem 13 Write a Bourne shell script for Problem 16 in Chapter 15, but use functions to implement the service code for various options. Modify the script in the `case_demo` file in Section 15.6.6 so that it allows you to try any number of options and quits only when you use the q option. ```bash $ sh bin/problem-13.sh Use one of the following options: d: To display today's date and present time l: To see the listing of files in your present working directory w: To see who's logged in q: To quit this program Enter your option and hit : d Sat May 25 19:52:41 MDT 2019 Use one of the following options: d: To display today's date and present time l: To see the listing of files in your present working directory w: To see who's logged in q: To quit this program Enter your option and hit : l bin Gemfile Gemfile.lock node_modules package.json pkg Rakefile README.md README.pdf test tmp vendor yarn.lock Use one of the following options: d: To display today's date and present time l: To see the listing of files in your present working directory w: To see who's logged in q: To quit this program Enter your option and hit : w mokha tty2 2019-05-21 20:12 (tty2) Use one of the following options: d: To display today's date and present time l: To see the listing of files in your present working directory w: To see who's logged in q: To quit this program Enter your option and hit : q ```