代写 html shell operating system software Syracuse University CIS 657: Principles of Operating Systems Spring 2020

Syracuse University CIS 657: Principles of Operating Systems Spring 2020
PA1: UnixLinux BASH Programming
Total points: 100 pts Due on Tuesday Feb 4, 2020 at 11:59 PM
Instructor: Endadul Hoque Logistics
1. This assignment must be done individually, not in groups.
2. For this programming assignment PA1, you have to download an archive called studentpa1.tar.gz
from Blackboard. Upon extraction, you will see a directory named student, which contains 6 directories
named task1, task2, and, so on one of each task.
3. For each task, you have to complete a shell BASH script provided in the respective directory. For
instance, for Task1, you have to complete solution1.sh located in task1 directory.
4. Unless stated otherwise, you must not modifyeditrenamemove other existing files under the student
directory.
5. For all the following tasks, you have to use the Linux server lcsvccis486.syr.edu dedicated for
this course. You must know how to remotely login to that machine, how to use terminal and how to
copy files back and forth between your computer and the Linux server.
6. Note that for solving each task you may need several commands, possibly combining them with pipes.
Some helpful links are listed in Appendix B.
Obtain the source code for this PA
Obtain studentpa1.tar.gz from blackboard. Unpack the package to find the skeleton code required for this PA. The extracted directory is named student.
Submission Instructions
1. Change directory cd to your student directory. Now student should be your current working directory.
2. Use your netid to create a compressed archive netidpa1.tar.gz of your solution directory. For instance, if your netid is johndoe, create a compressed archive as follows:
3. Use Blackboard to submit your compressed archive file e.g., johndoepa1.tar.gz.
tar xzf studentpa1.tar.gz
cd .. moving to the parent directory
mv student johndoepa1
tar czf johndoepa1.tar.gz johndoepa1
Page 1 of 5

Grading
We will use an automated grading tool with predetermined inputs to check your solution for correctness.
Please make sure you follow the instructions provided throughout this handout; otherwise your assignment will not be graded at all by the auto grader.
You must not renamemove solution.sh files under each task directory.
You must not modifyeditrenamemove other existing filesdirectories in student or in its sub
directories.
You must follow the naming convention for each task as directed, while creating files, directories, archives, and so on.
Your solutions must execute on the Linux machine lcsvccis486.syr.edu, otherwise your solutions will not be considered for grading.
Your must follow the submission instructions, or it will not be graded properly by the auto grader. Task 1 10 pts
Complete the BASH script location: task1solution1.sh so that it first creates a directory named Assignment1 in the current folder i.e., task1. Inside the Assignment1 directory, you will then create 10 directories named Query1, Query2, . . ., Query10. Inside each Queryi where i is in 1, 2, . . . , 10, create a file called responsei.sh.
Example: For instance, inside directory Query7, your script should create a single file named response7.sh. Hint: use mkdir, whilefor
Task 2 10 pts
Complete the BASH script location: task2solution2.sh so that it recursively finds all the files with .c extension inside the current directory i.e., task2 and archives these files as a tar file named allcfiles.tar. While creating the archive file, your script should exclude all other files and should not maintain the directory structure for these .c files.
Hint: use find, tar, xargs Task 3 15 pts
Complete the BASH script location: task3solution3.sh so that it reads the file proccpuinfo, determines the following values only the numbers, and outputs each of them on a separate line in a file called cpuinfo.txt, while adhering to the same order as shown below.
First line The total number of processors
one line for each processor Core id of each processor
one line for each processor Cache size available to each processor
Page 2 of 5

Example: Consider a machine with 2 processors and cat proccpuinfo on this machine produces the following output: NOTE: … represents one or more omitted lines of text; the numbers shown in this example are imaginary
processor

core id

cache size

processor

core id

cache size

: 0
: 0
: 128 KB
: 1
: 1
: 256 KB
cpuinfo.txt should contain the values only the numbers, NOT THE TEXT as follows when your script is run on a this machine:
Explanation of the previous cpuinfo.txt:
Hint: use cat, grep, awk, IO redirection e.g., , Task 4 15 pts
Complete the BASH script location: task4solution4.sh so that it kills all occurrences of a process called infloop. To test your BASH script, execute the given script named spawner.sh first. It will create 10 copies of the infloop process.
Hint: use ps ef; grepawk; kill 9; xargs
Check the usage of u option of ps. Use u option to ensure that your script kills only the infloop processes created by you, not by other users.
2
0
1 128 256
2 total number of processors
0 core id of processor 0
1 core id of processor 1
128 cache size available to processor 0
256 cache size available to processor 1
Page 3 of 5

Task 5 25 pts
Complete the BASH script location: task5solution5.sh so that it operates the following:
1. Download a tar file named sample data.tar from an URL that will be provided as a command line argument to your script. Hint: Inside the script, use 1 to refer to the URL
2. Extracts the tar file in the current directory to obtain the directory called sample data
3. Search through the content of the files inside sample data for string smart. Print how many times
this string appear in each file. The output should be written to a file named result.txt.
Output format one line for each file: printf s smart dn filename count, assum ing filename and count represent the file name and the number of times the desired string appeared in the file, respectively.
4. Search through the content of the files inside sample data for string operating system. Print how many times this string appear in each file. The output should be written technically speaking, appended to the same file named result.txt.
Output format one line for each file: printf s operating system dn filename count, assuming filename and count represent the file name and the number of times the desired string appeared in the file, respectively.
5. This script should also create two directories named smart and OS in the current directory i.e., task5. It will then copy all the files that contain the string smart respectively, operating system into the directory named smart respectively, OS.
To test your script on lcsvccis486.syr.edu, you can use http:127.0.0.1:55005sample data.tar as a command line argument.
Hint: use wget; grep; cat; wc
Task 6 25 pts
Complete the BASH script location: task6solution6.sh so that it operates as follows:
1. Extract input.tar.gz a compressed archive provided in the current directory task6. Hint: use tar with specific options for decompressing a gzipped tarball
2. From the extracted directory input, the script should move the files with .txt extension to a directory named TXT. You need to create the directory TXT first.
3. From input, the script should move the files with .jpg extension to a directory named JPG. You need to create the directory JPG.
4. From input, the script should move the rest of the files to a directory named ZIP.
5. The ZIP directory should then be compressed and archived. The name of this compressed archive should
be rest zipped.tar.gz.
Hint: Use tar, find, xargs, mv
Page 4 of 5

Appendix A: How to execute a bash script?
There are two approaches to execute a script say, solution1.sh. Approach 1
Approach 2
Appendix B: Some Useful Links
BASH Programming Introduction HOWTO: http:tldp.orgHOWTOBashProgIntroHOWTO.html
Bash scripting tutorial: https:ryanstutorials.netbashscriptingtutorial
BASH IO redirection: a http:tldp.orgHOWTOBashProgIntroHOWTO3.html,
b https:catonmat.netftpbashredirectionscheatsheet.pdf
BASH pipes http:tldp.orgHOWTOBashProgIntroHOWTO4.html
BASH printf: https:linuxconfig.orgbashprintfsyntaxbasicswithexamples
BASH Conditional Expressions: https:www.gnu.orgsoftwarebashmanualhtmlnodeBashConditionalExpressions.html
BASH Error Status:
a http:tldp.orgLDPabshtmlexitcodes.html,
b https:support.circleci.comhcenusarticles360002341673IdentifyingExitCodes
andtheirmeanings, c https:shapeshed.comunixexitcodes
Linux Error Codes: https:www.thegeekstuff.com201010linuxerrorcodes
grep command cheatsheet: https:ryanstutorials.netlinuxtutorialcheatsheetgrep.php
Linux tutorial Cheatsheets: https:ryanstutorials.netlinuxtutorialcheatsheet.php
LinuxCommand.org: http:linuxcommand.orgindex.php
BASH commands: https:linuxize.comtagsbash
Linux commands: https:linuxize.comtagsterminal
SSH commands: https:linuxize.compostsshcommandinlinux
Linux File System https:www.youtube.comwatch?vHbgzrKJvDRw
cd task1
chmod x solution1.sh
.solution1.sh
cd task1
bash solution1.sh
Page 5 of 5