Question
I am required to write a Bourne Again Shell Script (bash) to manage a menu driven program. When executed the user should be presented with
I am required to write a Bourne Again Shell Script (bash) to manage a menu driven program.
When executed the user should be presented with a menu with 4 (four) options:
1. Print the following user information: the home directory, path, userid , login shell together with the current date and time.
2. Ask a user a range and it displays eight random number between the range. [Range difference must be 100. Example Enter a range: 200 300
3. Print out the highest and the lowest numbers of the generated eight random numbers
4. Exit the program Requirements:
Your script must allow one of these options to be chosen at a time.
The menu must be presented over and over again, until the fourth option (exit) is chosen. An appropriate error message must be displayed if an invalid option is chosen.
Option one, your script should list the specified environment variables. The current output of the date command, together with the userid and the full name of the user also needs to appear in this file, before the environment variables.
Option two should prompt the user a range and displays eight (8) random numbers.
Option three should list the highest and lowest number of the generated random numbers.
Option four should cause a graceful exit from the menu and the whole program
================================================================
The problem is Question 2 and 3.
I have to make eight random numbers and it should list the maximum and minimum of the generated random numbers.
So i made the script. But the output is same eight numbers.
How to fix it ? plz let me know correct coding. and explaining plz.
one more thing is ...What does "$RANDOM=$$" mean? I just know it is a pre-defined shell variable, which will gives process id of the current shell script.
But I dont understand it exactly. Plz explain it easily with examples.
echo "Enter starting range" read m echo "Enter ending range" read n if Sdir-ne 100 then echo " -m difference is Sdif" echo "the difference should be Hundred" else dif=S ( (Saif + 1)) RANDOM-SS min max echo "Eight Random integers between n and Sm are..." echo for seq ? 0 echo in -ge SR 1 then min Smax-le SR then max done
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started