BOS (basics of operating system)
A microproject of Linux commands that ask the user for input and give a
maximum of 3 attempts
Submitted to
VPMP Polytechnic, Gandhinagar
Department of Computer Engineering
Guide Name:
Mrs. K. H. Mistry
Prepared By:
Shubham Prajapati
(226540307162)
Yana Makadia (226540307210)
Krish Patel (226540307128)
Yuvraj Solanki (226540307186)
Case study on a shell script (linux shell script) that asks the user
for a password until it is correct and gives a maximum of 3
attempts.
Here, a shell script is written that asks the user for input until it
is correct and gives a maximum of 3 attempts.
Here, the password is Bos. System will ask the user for a
password, if that entered password is correct, it’ll return
“Access granted. Welcome!”
If the entered password is incorrect, then the system will
return “Incorrect password" and will return the number of
attempts remaining.
Step wise explaination of script:
1|Page
Step 1: Open Cygwin Terminal 64.
Step 2: In Cygwin terminal 64, the command to open or create
a new file is “vi filename.sh” In this command to open the vi
editor, filename is the file to be created or opened. Here we
named our file "project.sh”.
Step 3: After opening the project.sh file, we’ll write a script.
Step 4: After that, we will compile that script and execute it.
Step 5: To quit Vi Editor with changes, we use “esc then ZZ.”
Step 6: After quitting Vi Editor, we will compile the script. To
compile the script, the command is “chmod u+x filename.sh”,
As our filename is project.sh, we will write “chmod u+x
project.sh”.
Step 7: After compile script we will execute it using
"./filename.sh." As our filename is project.sh, we will write
“./project.sh”.
Step 8: If our script has no errors, it will be executed
successfully.
Bos case study on shell script
Use of commands that we have used:
-gt: In Linux, the “-gt” command is used as greater than.
read: In Linux, the “read” command is used for taking input
from the user.
-p: In Linux, “-p” is used with the read command to display the
prompt and store entered values in variables.
fi: In Linux, “fi” is used to terminate a selection statement.
-eq: In Linux, “-eq” is used as an equal’s operator.
esc then ZZ: In Linux, “esc then ZZ” is used for quit vi editor
with changes.
Used commands in execution of the script:
chmod u+x project.sh: In Linux, this command is used
to debug the script.
./project.sh: In Linux, this command is used to
run/execute the script.
2|Page
Bos case study on shell script
Script:
Script Output:
3|Page
Bos case study on shell script