Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

UNIX Shell Programming For this exercise you are required to make a copy of the following script into a file named guess.sh : #!/bin/tcsh -f

UNIX Shell Programming

For this exercise you are required to make a copy of the following script into a file named guess.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 the slides about Shell Overview and Shell Programming with the description of what it does. Your task is to incorporate comments in different parts of the script to explain what it does.
  2. Execute the script and correct any error it may have to run it. You will have to change permissions to the shell script file to make it executable (remember the chmod command).
  3. You are required to modify the script, make a copy with the name guess_game.sh and implement the following changes:
    1. Create a main menu, so when you execute the script the user will have two options (try the command clear to clean the screen):

1.Run the guessing game

2.Exit

  1. When the user selects run the game, the game will do the same thing with an addition. It should now keep a record of each score.
  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 print out to the screen the different scores for each game that was played:

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 of any help.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions