Open main menu

CDOT Wiki β

Changes

OPS245 Lab 1 dev

395 bytes added, 14:04, 7 January 2023
INVESTIGATION 5: Using Python Scripting to Generate System Information Reports
<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; Call the date command using the os moduleos.system(date)</pre><li>Save your script and run it again. Observe the output.</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>