Open main menu

CDOT Wiki β

Changes

OPS245 Lab 2

6 bytes added, 13:06, 13 July 2021
INVESTIGATION 4: USING PYTHON TO AUTOMATE MANAGING VIRTUAL MACHINES
<li>Modify the if statement so it is just getting the current username, not the username and a newline. You can do this using several steps and several variables, but it can also be done in a single line.</li>
<li>Now that the script recognizes you as being root (or at least running the script with root permissions), it should work. Notice how we've used the + to combine several strings together to pass to the os.system command. We did this because this script needs the python variable to be evaluated before the whole line gets handed over to os.system. If you left the variable names inside the quotes, python will ignore them as just being part of a string. By putting them outside of a string, and concatenating their value to that string, we can evaluate them and feed them into that command.</li>
<li>'''Convert the rest of the bash script above into python, then test your python version to make sure it works.'''</li>
</ol>
572
edits