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

Linux terminal Using Bash 5) Create a script named lab6s5 that plays a game with

ID: 3737003 • Letter: L

Question

Linux terminal Using Bash

5) Create a script named lab6s5 that plays a game with the user. When a user executes the script, they must keep guessing the secret number until they successfully enter it. Here is an example interaction with the script. Make sure that your script behaves identically:

$ ./lab6s5

I am thinking of a number between 1 and 10. Enter your guess:3

The secret number is larger than your guess. Try again.

I am thinking of a number between 1 and 10. Enter your guess:6

The secret number is smaller than your guess. Try again.

I am thinking of a number between 1 and 10. Enter your guess:2

The secret number is larger than your guess. Try again.

I am thinking of a number between 1 and 10. Enter your guess:5

Yes! 5 is the correct answer!

6) Create a script named lab6s6 that accepts TCP connections. When a client connection occurs, send the time of day as a response to client. You may choose any port number as the listening port, and don’t forget to close your connections.

7) Create a script named lab6s7 that calculates and prints your final grade for this class.

Explanation / Answer

#guessing a number and fitting it into a range 1 to 10

rand=$(($RANDOM%10+1))

echo 'I am guessing a number from 1 to 10'

echo 'Enter your guess'

read guess

#loop untill the condition is satisfied

while (($guess!=$rand)) ; do

   if [ $guess -lt $rand ]

   then

      echo 'Your guess is less than the secret number.'

   else

      echo 'Your guess is greater than the secret number.'

   fi

   echo 'Enter your guess'

   read guess

done

echo 'you guessed it! The number was ' $guess

echo 'Bye!!'

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote