📙
Workbook - Introduction to Software Systems
  • About - Workbook
  • Introduction
  • Software Engineering
    • Software Systems
    • Software Product Development
    • Networking
  • TERMINAL PROGRAMMING
    • LINUX - SHELL
    • Practice Questions
  • Web Technologies
    • HTML
    • CSS
    • JavaScript
  • Databases
    • Database Systems
    • SQL - CURD Operations
  • Object Oriented Programming
    • Python
  • Lab Activities
    • Understanding GIT - Lab 1
    • SHELL - Lab 2
      • Class Quiz (15/6/2021)
      • Class Test Script
      • SHELL Lab Activity Task
      • SHELL Lab Activity Solution
  • ASSIGNMENTS
    • Assignment-1 SHELL Solutions
Powered by GitBook
On this page
  • UPDATE:
  • Question
  • Corrected Script
  • Key

Was this helpful?

  1. Lab Activities
  2. SHELL - Lab 2

Class Test Script

Please go through the following script and identify the defects

UPDATE:

There was an issue with the way the MS Forms was created. So we have updated the Key below.

Question

!#/bash/bin
echo Please talk to me ...
while 
do
  read INPUT_STRING
  case INPUT_STRING 
        hello) echo "Hello yourself!" ;;
        bye)   echo "See you again!" break ;;
        #)     echo "Sorry, I don't understand" ;
  esac
echo
echo "That's all folks!"

Corrected Script

#!/bin/bash
echo "Please talk to me ..."
while true
do
  read INPUT_STRING
  case $INPUT_STRING 
        hello) echo "Hello yourself!" ;;
        bye)   echo "See you again!" break ;;
        *)     echo "Sorry, I don't understand" ;;
  esac
echo
echo "That's all folks!"

Key

Highlighted responses are correct

Q1: Which of the following are correct for the provided Bash Script?

  • Line 1: !#/bash/bin - This is incorrect - It should be #!/bin/bash

  • Line 2: echo Please talk to me ... - This is correct

  • Line 3: while - This is incorrect - it should as per the above solution to let the WHILE loop run

  • Line 5: read INPUT_STRING - This is correct

Q2: Which of the following are incorrect in provided Bash Script?

  • Line 1: !#/bash/bin - This is incorrect - It should be #!/bin/bash

  • Line 2: echo Please talk to me ... - This is correct

  • Line 3: while - This is incorrect - it should as per the above solution to let the WHILE loop run

  • Line 5: read INPUT_STRING - This is correct

Q3: Which of the following are missing in the provided Bash Script?

  • Line 11: done - As it is required to end the WHILE loop

  • Line 6: case $INPUTSTRING in - As we need to read the value of INPUT_STRING in case

  • Line 5: echo - It is not required as it doesn't matter if echo existed or not. So it is not considered missing.

  • None of the Above - Obviously not an answer here.

Q4: Which of the following is true for Line 9?

  • should be replaced by *

  • The line should end with ;;

  • *) echo "Sorry, I don't understand" ;; - is the correct final replacement

  • None of the above - Obviously not an answer here.

Q5: Which of the following correct in regards to the provided Bash Script?

  • The script takes in an input from console and responds based on CASE statements and repeated in WHILE loop

  • The scripts takes in an input from console and responds only based on WHILE loop

  • The script is completely incorrect and does nothing

  • None of the options are correct

PreviousClass Quiz (15/6/2021)NextSHELL Lab Activity Task

Last updated 3 years ago

Was this helpful?