Python Example – headache.py

Python Example – headache.py
While working on a python script a few day’s ago I got frustrated, and bored so I decided to take a break, and write something less than useful. So I did, and then realized it might make a good very basic python example, utilizing a single function, including modules, and pattern matching. You can play around with it by changing the file name. Setting it to headache.py will return the expected results “true”, otherwise it will return nothing. #!/usr/bin/python import sys   def headAche(): if str(sys.argv[0]) == "headache.py": print...
read more

Calling functions with pattern matching in bash

Calling functions with pattern matching in bash
This script is pretty simple in its functionality, however it shows how you can utilize passing bash arguments to get different results, or to call different functions within the script. In this example we are just echoing out the argument that is being passed, but only if it matches what the script is looking for. These types of functions are particularly useful if you have a multi function script which changes its behavior depending on the arguments which are passed to it. #!/bin/bash   function init() {   if [ "${1}" == "string1" ]; then...
read more