Open main menu

CDOT Wiki β

Changes

OPS245 Lab 2

No change in size, 17:47, 9 January 2021
m
UNDER CONSTRUCTION: - fixing a typo
&nbsp;&nbsp;for machine in {'centos1','centos2','centos3'}:<br />
&nbsp;&nbsp;&nbsp;&nbsp;print('Backing up' + machine)<br />
&nbsp;&nbsp;&nbsp;&nbsp;os.system('gzip < /var/lib/libvirt/images/' + machine + '.qcow2 > ~/backups/' + machine + '.qcow2.gz')<br />
</code>
<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>
</ol>
 
= LAB 2 SIGN-OFF (SHOW INSTRUCTOR) =
932
edits