Question
cs3423 Assignment 2 SED This assignment has two parts p2a and p2b. Problem A: We need a new mechanism to identify apps that have been
cs3423 Assignment 2 SED
This assignment has two parts p2a and p2b.
Problem A:
We need a new mechanism to identify apps that have been installed on the system and have never been removed. We will use the dpkg.log file to get information of the installation history; however, it just handles one server. You can find dpkg.log in "/usr/local/courses/rslavin/cs3423/2018Sp/assignment2". Copy this file to your project directory.
The format of the dpkg.log is similar to this (the yellow highlighted portions are comments):
The following line is a command to remove grublegacyec2.
20160323 20:54:27 remove grublegacyec2:all 0.7.50ubuntu1.17
The following status lines are intermediate steps in the removal of the grublegacyec2 program
20160323 20:54:27 startup packages purge
20160323 20:54:27 status configfiles grublegacyec2:all 0.7.50ubuntu1.17 20160323 20:54:27 status configfiles grublegacyec2:all 0.7.50ubuntu1.17
The following is an example of a short command | ||
20160913 02:42:27 | install | language |
packenbase:all
20160913 02:42:27 startup archives unpack
20160913 02:42:27 status halfinstalled languagepackenbase:all 1:14.04+20160720
20180119 21:33:09 install flex:amd64
20180119 21:33:09 status halfconfigured mandb:amd64 2.6.7.11ubuntu1
20180119 21:33:09 status halfinstalled flex:amd64 2.5.3510.1ubuntu2
20180119 21:33:09 status triggerspending installinfo:amd64 5.2.0.dfsg.12
20180119 21:33:09 status triggerspending mandb:amd64 2.6.7.11ubuntu1
20180119 21:33:14 status installed libfldev:amd64 2.5.3510.1ubuntu2
20180119 21:33:14 status unpacked flex:amd64 2.5.3510.1ubuntu2
20180119 21:33:14 status unpacked libfldev:amd64 2.5.3510.1ubuntu2
remove |
remove |
20180119 21:33:25 flex:amd64 2.5.3510.1ubuntu2
20180119 21:33:25 libfldev:amd64 2.5.3510.1ubuntu2
20180119 21:33:25 startup packages remove
20180119 21:33:25 status configfiles flex:amd64 2.5.3510.1ubuntu2
20180119 21:33:25 status configfiles flex:amd64 2.5.3510.1ubuntu2
20180119 21:33:25 status configfiles libfldev:amd64 2.5.3510.1ubuntu2
Find any program which has been installed but not removed from this file. For instance, in the example above the program languagepackenbase (5th line) meets the criteria but the program flex (8th line) does not since it was removed later.
We suggest creating two files, one with all the installed programs and one with all the removed programs, and using the difference of the two to find only those who have been installed but not removed. Example:
Installed file:
languagepackenbase flex
Removed file:
grublegacyec2 flex libfldev
Matching on install.
Where is the word install we want to match which indicates that the program was installed? If we just match "install" anywhere on the line, it could match programs which have the word install in the name. Also, we would match status lines (e.g., status installed) that are only intermediate steps in the installation.
File difference.
We can use the comm command to find the lines that are unique across two files. Note that comm expects the files to be sorted. See the comm man page for details.
Problem B:
For this problem, we will want to get the same result, but this time we are going to consider if a program was installed again after being removed.
Steps:
Consider using the installed/removed files from the previous problem
The uniq c command can be used to get a count of each unique value
Then you only need to find those items which have a higher install count than removed count
You may use intermediate output files to store programs and their install/remove counts, just be sure to remove them by the end of execution
Hint: grep can be used to search a particular file using a regular expression. If you can identify the number of installations for an application, you can use grep to search for the same application in your temporaryuninstallcount file to compare values.
What to turn in
A LastnameFirstname.zip file containing at least the following: o p2a.bash a bash script which executes part A. The final result should be output to p2a.out using p2AInstalled.sed and p2bRemoved.sed
o p2aInstalled.sed a sed file which produces records of installed files o p2bRemoved.sed a sed file which produces records of removed files o p2b.bash a bash script which executes part B. The final result should be output to p2b.out
Be sure that your scripts remove any intermediate files created. After running p2a.bash and p2b.bash (the only scripts which should be run), the only new files that should exist are p2a.out and p2b.out.
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