From 83d3bae6b09e870f15a39edfa01e93ff6ea0b6a0 Mon Sep 17 00:00:00 2001 From: mo Date: Sat, 25 May 2019 19:55:32 -0600 Subject: update README --- README.md | 83 +++++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 59 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index df1ddf0..073483b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,18 @@ # 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. +> 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. To run +the tests you will need to install [bats](https://github.com/sstephenson/bats). +To make installation easier, I have included [bats](https://github.com/sstephenson/bats) as a git submodule. + +```bash +$ git submodule update --init +$ sh ./bin/test +``` ## Chapter 16 @@ -10,34 +20,59 @@ 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. -```text -#!/bin/sh -echo "Use one of the following options:" -echo " d: To display today's date and present time" -echo " l: To see the listing of files in your present working directory" -echo " w: To see who's logged in" -echo " q: To quit this program" -echo "Enter your option and hit : \c" -read option -case "$option" in - d) date - ;; - l) ls - ;; - w) who - ;; - q) exit 0 - ;; -esac -exit 0 +```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 ``` -- cgit v1.2.3