Write a python program to do the following. The program will essentially complet
ID: 3645710 • Letter: W
Question
Write a python program to do the following. The program will essentially complete a process of removing IP addresses from a set of files and replacing them with the corresponding fully qualified domain name. There are two options controlling the execution:(-d) this option can specify the name of a file that should contain a report concerning the substitutions performed, its default value is sub.report stored in the current working directory
(-r) if this option is given then files contained in subdirectories of specified source directories should also be searched, by default only the top level of the source directories are processed.
The options will be followed on the command line by a potential list of directory names. If this list is empty, the current working directory should be searched. You should validate that any names given indeed are directories that exist, and that the report file does not already exist. The program should terminate if errors exist.
The script will look through the contents of each source directory trying to find regular files that do not have their execution permission bits set. For every such regular file that is found, a substitution process will be performed. You should search for IP addresses in the contents of the file. For every address that is found, it will be replaced by text according to the following guidelines:
(1) the phrase private-IP-address will replace addresses that are of the form 192.168.x.x, 10.x.x.x,
and 172.16-31.x.x (the second value is between 16 and 31).
(2) the phrase unknown-name will be used if it is not a private address and the DNS system is not able to resolve the address into a name.
(3) the resolved DNS name will be used for all other addresses.
A new version of the file should replace the old version.
In addition to doing the actual substitution, entries should be added to the report file. The entry should include the name of the file, followed by separate lines of the form: IP address -> substituted phrase.
Explanation / Answer
Answer: (2). the phrase unknown-name will be used if it is not a private address and the DNS system is not able to resolve the address into a name. (3). the resolved DNS name will be used for all other addresses.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.