Operating System Project: Shell Scripting and Random Numbers

Verified

Added on  2020/05/08

|10
|593
|75
Project
AI Summary
This project presents a shell script developed for managing operating system functions. The script includes features such as displaying system information, generating random numbers within a specified range, and identifying the maximum and minimum values within the generated set. The script is designed to take user input, offering options to view system details, generate random numbers, and exit the program. The project also includes a reference to relevant literature, such as "Shell Programming in Unix, Linux and OS X" and "Advanced programming in the UNIX environment". This assignment provides a practical demonstration of shell scripting, which can be beneficial for students studying operating systems and system administration. This assignment is available on Desklib, a platform that provides AI-powered study tools for students, where students can find past papers, solved assignments, and other resources to aid in their studies.
Document Page
Running head: OPERATING SYSTEM
Operating System
Name of the Student
Name of the university
Author’s Note
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
1
OPERATING SYSTEM
Table of Contents
Bourne Again Shell Script in bash for the management of the menu driven program........2
Outputs.................................................................................................................................6
Bibliography........................................................................................................................9
Document Page
2
OPERATING SYSTEM
Bourne Again Shell Script in bash for the management of the menu driven
program
#!/bin/bash
# + Username
# + Date and Time
# + Who is logged in
# + output line of asterics
# function for displaying a line of asterics
echo "enter any option"
options=("1" "2" "3" "4")
select opt in "${options[@]}"
do
function line(){
echo "*******************************"
}
case $opt in
"1") clear
echo "home directory : $(ls)"
Document Page
3
OPERATING SYSTEM
line # call function
echo "path : $(echo $PATH)"
line
echo "userid : $(id -u)"
line
echo "Currently logged on users:"
who
line ;;
"2") #This script accepts two integers from the user
#and generates 8 random numbers from it
#Author: Student_Name
#Date: Oct 2017
echo "Enter the lower and the upper limits:"
read a
read b
echo "The generated random number are: "
IFS=$'\n'
nos=($(shuf -i $a-$b -n 8))
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
4
OPERATING SYSTEM
printf "%s\n" "${nos[@]}"
;;
"3") #This script generates the
#maximum and the minimum number from
#the generated random number
#Author: Student_Name
#Date: Oct 2017
echo "The generated random number between the limits are:"
IFS=$'\n'
nos=($(shuf -i $a-$b -n 8))
printf "%s\n" "${nos[@]}"
max=${nos[0]}
min=${nos[0]}
# Loop through all elements in the array
for i in "${nos[@]}"
do
# Update max if applicable
Document Page
5
OPERATING SYSTEM
if [[ "$i" -gt "$max" ]]; then
max="$i"
fi
# Update min if applicable
if [[ "$i" -lt "$min" ]]; then
min="$i"
fi
done
echo "Max is: $max"
echo "Min is: $min"
;;
"4")
#This option exits from the loop
#Author: Student_Name
#Date: Oct 2017
break
;;
Document Page
6
OPERATING SYSTEM
*) echo "invalid entry" ;;
esac
done
Outputs
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
7
OPERATING SYSTEM
Document Page
8
OPERATING SYSTEM
Document Page
9
OPERATING SYSTEM
Bibliography
Kochan, S.G. and Wood, P., 2016. Shell Programming in Unix, Linux and OS X. Addison-
Wesley Professional.
Rybczyński, M., Stefanek, G., Broniowski, W. and Bożek, P., 2014. GLISSANDO 2: GLauber
Initial-State Simulation AND mOre…, ver. 2. Computer Physics Communications, 185(6),
pp.1759-1772.
Shen, Z., 2015. A Gentler Introduction to Unix.
Stevens, W.R. and Rago, S.A., 2013. Advanced programming in the UNIX environment.
Addison-Wesley.
chevron_up_icon
1 out of 10
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]