Menu
support@nursinghomework.org
+1 714-215-3097

(Solved) : Unix Shell Programming Exercise Required Make Copy Following Script File Named Guesssh Bin Q35603086

UNIX Shell Programming

For this exercise you are required to make a copy of thefollowing script into a file namedguess.sh:

#!/bin/tcsh -f

echo “guess the number”

set answer = $<

set goal= `tr -dc A-Za-z0-9 </dev/urandom | od -d | head -c 10 | tr -d 0 | tr -d ‘ ‘`

set count = 1

while ($answer != $goal )

    if ($answer <$goal ) then

        echo “too small”

    else

        echo “too large”

    endif

    @ count ++

    set answer =$<

end

echo “correct!”

echo “using $count rounds”

  1. Study the script and be sure to understand it. Review theslides about Shell Overview and Shell Programming with thedescription of what it does. Your task is to incorporatecomments in different parts of the script to explain what itdoes.
  2. Execute the script and correct any error it may have torun it. You will have to change permissions to the shellscript file to make it executable (remember the chmodcommand).
  3. You are required to modify the script, make a copy with thename guess_game.sh and implement thefollowing changes:
    1. Create a main menu, so when you execute the script the userwill have two options (try the command clear to clean thescreen):

1.Run the guessing game

2.Exit

  1. When the user selects run the game, the game will do the samething with an addition. It should now keep a record of eachscore.
  2. When finishing the game, the script returns to the main menu,so the user can play again
  3. When the user selects Exit, the script before ending will printout to the screen the different scores for each game that wasplayed:

Exiting the guessing game

Your average of rounds is:calculated average

Your scores are:

5

6

4

3

4

  1. See if using the exit status of a command may be ofany help.

Leave a Reply

Your email address will not be published. Required fields are marked *