Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please help Using the five shell scripts in Shell Script ( addtwo.sh , logincoun

ID: 3830029 • Letter: P

Question

please help

Using the five shell scripts in Shell Script (addtwo.sh, logincount.sh, lsdirs.sh, see.sh, and wordlen.sh), create a master shell script called master.sh which displays on the screen a menu selection of items which the end-user can select from to run each of the scripts in turn. Assume all the scripts are located in the same directory. The master shell will keep looping until the user enters a value to quit from the shell script. You must also make accommodation for an invalid selection by issuing an error message to the user.

The main menu selection should be shown on the screen as shown below and will keep displaying the menu selection until the user selects option 6 to quit. (Hint: Use a CASE statement within a WHILE statement to do the continuous looping).

$ master.sh

Select which shell script you wish to run.

addtwo.sh

logincount.sh

lsdirs.sh

see.sh

wordlen.sh

quit

Enter your selection: _ (This is where the cursor should be for the input selection)

Since the shell scripts take command line arguments, you will also be required to ask the user to enter the command line arguments for each shell script and then pass those values on to the shell script as a command line argument.

Explanation / Answer

// script1:

#!/bin/bash
# set an infinite loop
while :
do
   clear
   echo "select which script you wish to run"
   echo "1. addtwo.sh"
   echo "2. logincount.sh"
   echo "3. lsdirs.sh"
   echo "4. see.sh"
   echo "5. wordlen.sh"
   echo "6. quit"
# get input from the user
   read -p "Enter your selection:_" choice
# make decision using case..in..esac
   case $choice in
       1)
           echo "Executing addtwo.sh ..."  
           echo "Supply arguments for script addtwo.sh: "
           read input_param
           ./addtwo.sh input_param
           read -p "Press [Enter] key to continue..." readEnterKey
           ;;
       2)
           echo "Executing logincount.sh ..."  
           echo "Supply arguments for script addtwo.sh: "
           read input_param
           ./logincount.sh input_param
           ;;
       3)
           echo "Executing lsdirs.sh ..."  
           echo "Supply arguments for script addtwo.sh: "
           read input_param
           ./lsdirs.sh input_param
           ;;
       4)
           echo "Executing see.sh ..."  
           echo "Supply arguments for script addtwo.sh: "
           read input_param
           ./see.sh input_param
           ;;
       5)
           echo "Executing wordlen.sh ..."  
           echo "Supply arguments for script addtwo.sh: "
           read input_param
           ./wordlen.sh input_param
           ;;
       6)
           #exit 0
           return
           ;;
       *)
           echo "Error: Invalid option..."  
           read -p "Press [Enter] key to continue..." readEnterKey
           ;;
   esac      
done

// script 2

#!/bin/bash
echo "Hello from see.sh"

// script3

#!/bin/bash
echo "Hello from wordlen.sh"

// script 4

#!/bin/bash
echo "Hello from addtwo.sh $1"

// scirpt 5

#!/bin/bash
echo "Hello from logincount.sh"

// script 6

#!/bin/bash
echo "Hello from lsdirs.sh"