Open main menu

CDOT Wiki β

Changes

OPS245 Scripting Exercises

840 bytes added, 13:23, 2 September 2023
no edit summary
{{Admon/caution|DO NOT USE THIS VERSION OF THE COURSE. This page will no longer be updated.|'''Debian version here:''' https://seneca-ictoer.github.io/OPS245
<br>'''CentOS version here:''' https://seneca-ictoer.github.io/OPS245-C7}}
= Things on this page =
== Conditional statements ==
'''Bash'''
* if
* test, [
 
'''Python'''
*Python has conditional statements, we just haven't covered them yet.
= Exercises =
* Create a bash script that will print Hello, then list the contents of the / directory, then print Good Bye.
**Create a python script that does the same thing.
* Create a bash script that will run your other script twice.
** Run this new script from different locations, and see if it always works. Fix it if it doesn't.
* reate Create a bash script to display the contents of /etc/sysconfig/network-scripts/ifcfg-ens33
** Pipe the output to cat
*** Pipe that output to cat. See if you understand why that doesn't seem to do anything
** Save the result in a variable, and print that variable.
* Combine the two scripts above into one. The script should tell you what the value of BOOTPROTO from /etc/sysconfig/network-scripts/ifcfg-ens33 is.
*Create a python script that will prompt the user for the name of the interface they want to search (e.g. ens33), then prompt them for the parameter they wish to see.
**Store the responses from the user in variables and use them to grep the appropriate file for the parameter the user asked for. Display it's current value.
**Note: As we have not covered conditional statements or loops in python yet, you can assume the user always provides usable responses.
* Use the ls and wc commands to find how many log files there are in /var/log/
** Add a grep command to find how many of a certain type of log file there are (e.g. vmware-network log files)