Changes

Jump to: navigation, search

OPS245 Lab 1

889 bytes added, 16:55, 7 January 2023
LAB PREPARATION
| |[[Image:ssd.png|thumb|left|175px|<b>Solid State Drive</b><br>Minimum Size: 250GB]]
| [[Image:log-book.png|thumb|left|100px|<b>Lab Logbook</b><br>[[:Media:OPS245-Logbook-Online.doc|(lab 1Click Here to Download)]]]]
| style="padding-left:15px;" |Package Management
:'''Perform the Following Steps:'''
<ol>
<li>Install Check if python3 is installed on your Centos Host machine. Open a terminal and type:</li><code style="color:#3366CC;font-family:courier;font-size:.9em;margin-left:20px;font-weight:bold;">which python3</code><li>The output should of the previous command should show python3 is already installed. If it is not, install python3 on your Centos Host machine.</li>
<code style="color:#3366CC;font-family:courier;font-size:.9em;margin-left:20px;font-weight:bold;">
sudo yum install python3
<li>Add a line that will print out the heading '''System Report'''<br />
<code style="color:#3366CC;font-family:courier;font-size:.9em;margin-left:20px;font-weight:bold;">
print('System Report\n')
</code>
</li>
<li>Save your script and run it. Does it work?</li>
<li>You'll notice that the python script is currently sending its output to your terminal. Since we haven't covered how to write to a file yet, this is ok for now. Just use output redirection on the command line when you run the script to send the output to '''~/bin/pythonreport.txt'''.</li>
<li>Add Open your script in a text editor (like Vi) again, and add the following lines below the print statement:</li><pre style="color:#3366CC;font-family:courier;font-size:.9em;margin-left:20px;>&#35; Import the Operating System moduleimport os &#35; Print a heading for the date command outputprint('Current Date:') &#35; Call the date command using the os moduleos.system("date +'%A %B %d, %Y (%I:%M %p)'")</pre><li>Save your script and run it again. Observe the output. What do you think the os.system command did?</li><li>Based on the above example and output, add the extra commands for your python script to also output (with appropriate headings):
<ul>
<li>The current date.</li>
<li>The hostname of the machine.</li>
<li>The kernel version.</li>

Navigation menu