Open main menu

CDOT Wiki β

Changes

OPS245 Lab 6

1,311 bytes added, 17:47, 21 March 2021
Adding the scripting investigation.
'''Answer INVESTIGATION 2 observations / questions in your lab log book.'''
 
=INVESTIGATION 3: USING PYTHON TO MODIFY FILES=
 
In this investigation you will write a python script that will allow a user to interactively configure a network interface's configuration file. Before beginning, make a backup of your ifcfg files.
 
Write a script called '''netconfig.py''' that will prompt the user for the following values, and write their answers into an ifcfg file stored in the '''/etc/sysconfig/network-scripts''' directory.
 
#The name of the interface
#The interface's MAC address
#Whether the interface should automatically turn on when the machine boots.
#Whether the interface should get a static or DHCP address
::Note: Only prompt the user for the following values if they chose a static address.
::*The static ip address
::*The network prefix
::*The default gateway
::*The primary DNS server
 
Note that your script should make use of loops and try-except statements to make sure the user provided semi-reasonable data. You are not expected to create the regular expressions necessary to confirm the format of the IP address, but should be able handle simpler issues like forcing the user to give the interface a name (since you will need it for the filename), determining if it will start automatically, and the address type.
 
Remember to test your script to make sure it works.
= LAB 6 SIGN-OFF (SHOW INSTRUCTOR) =
# Run the shell script and if there are any warnings, make fixes and re-run shell script until you receive "congratulations" message.
#Arrange proof of the following on the screen:<br><blockquote><span style="color:green;font-size:1.5em;">&#x2713;</span> '''centos2''' VM:<blockquote><ul><li>'''ssh''' from '''centos2''' to '''c7host''' VM.</li></ul></blockquote><span style="color:green;font-size:1.5em;">&#x2713;</span>'''c7host''' machine<blockquote><ul><li>Output from running the '''network-info.bash''' shell script</li><li>Run the '''lab6-check.bash''' script in front of your instructor (must have all <b><code><span style="color:#66cc00;border:thin solid black;font-size:1.2em;">&nbsp;OK&nbsp;</span></code></b> messages)</li></ul></blockquote><span style="color:green;font-size:1.5em;">&#x2713;</span> '''Lab6''' log-book filled out.
#Upload a screen of the proof from the previous step, along with the file generated by '''lab6-check.bash''', and your network-info'''netconfig.bash py''' script to blackboard.
= Practice For Quizzes, Tests, Midterm &amp; Final Exam =
932
edits