Professional Documents
Culture Documents
Prerequisites
a) Boot up your CentOS Linux Box and open Terminal
Deliverables
A MS-Word file of all screenshots and Qs and Tasks, to be uploaded in Week9 DropBox
Total 10 points ( you lose one point for each wrong asnwer)
Due date: as written on Dropbox
Follow below instructions and create the scripts, make sure it runs properly as instructed.
Reminder: Bash Script Comparison Operators (I added arrows in next pages screenshots so
you could distinguish them) for scripting you need to remember them
CST8207_Linux Operating system I Algonquin College – Winter 2020
a) In W10, create a script file called autofile.sh , this script creates Dir1 and f1.txt in your
current directory automatically. Also it checks that the Dir1 and f1.txt exists or not before
creation. Enter below script code in the editor. Make sure you give execute permission
to script and execute it as below:
Directory
File
$ ./autofile.sh
d) Now complete the script the way to create below files and directories automatically
when you run it.
e) Make sure it works as desired and Run ls –l to show all your file are created
(Screenshot here) + ( Screen shot of your script)
Part 2
Login Script (String comparison)
This script ask for username from input, and verify that it matches with “bob” as username. If
username is correct it give “Username is OK!” or it notifies user that username is incorrect.
Now add another IF-Block to the script in order to ask for password and verify if the password
is “123” and give message “Password OK!” or “Incorrect Password!” to user.
Part 3
While Loop)
$ ./counter.sh
b) It uses while loop to count from 1 to 10. Screen shot of output here
CST8207_Linux Operating system I Algonquin College – Winter 2020
c) Now modify the script so you can pass the value of counter using positional parameters ($1)
e.g.
$ ./counter.sh 20
$ ./counter.sh 35
As such it counts up to 35
Part 4
FOR Loop)
a) Modify counter.sh script to use for loop instead of while. To do so you need to change the
while loop with a for loop as you see below:
b) It uses for loop to count from 1 to 10. Screen shot of output here
CST8207_Linux Operating system I Algonquin College – Winter 2020
c) Now modify the script so you can pass the value of counter using positional parameters ($1)
e.g.
$ ./counter.sh 20
so it counts upto 20 , or
$ ./counter.sh 35
so it counts up to 35
d) make sure it works and put your screenshot of results here ()
Challenge [has no mark] (Just for Practice): modify the script in FOR loop the way it shows 7 time
table similar to below: