I could rant about Python, I suppose. No curly braces? Where does this stanza end? How can an object not know who its "self" is? Why no "PCRE" style "s/this/that/g"? See, I sound old already.
Yet, Python does have advantages: It's quick to learn (the youngins love it, and that's always good), and it can be easier to read. "Pip" is far easier to use than CPAN, which was about as inviting as CSPAN. And Python's virtual machine does make it heavier and slower, but that gains us consistency across platforms.
So Python it is. Here you'll find various Python projects, experiments, and samples.
This script runs arbitrary system command(s) for a list of things, which (yes) could just as easily be accomplished at a shell prompt with a "for" command. But it also provides an interface to review and edit the command and "things", and stores that configuration inside itself - which I think is kinda' hilarious. See the full source on GitHub.
Iterator.py sample run
# Demonstration of "iterator.py" sample script # A self-contained general-purpose "Thing Doer" # See script source for details. # Gary Arthur Douglas Jr | unhacker@gmail.com [garyd@dizzymouse iterator]$ ./iterator.py typohere ./iterator.py: Invalid mode Typohere # iterator.py: Run a command on a list of things # Usage: # iterator.py show - Show config # iterator.py things - Edit list of things # iterator.py command - Edit command # iterator.py run - Execute current config # iterator.py help - You are reading it [garyd@dizzymouse iterator]$ ./iterator.py show Mode : Show Command : /tmp/brawl.py _THINGS_ Things : 21 63 20 34 85 [garyd@dizzymouse iterator]$ ./iterator.py things Mode : Things Number Thing ------- ------------ 0 21 1 63 2 20 3 34 4 85 [A]dd, [D]elete, or [S]ave/quit : d Enter number to delete, or nothing (to cancel): 0 Thing # 0 deleted! Number Thing ------- ------------ 0 63 1 20 2 34 3 85 [A]dd, [D]elete, or [S]ave/quit : d Enter number to delete, or nothing (to cancel): 3 Thing # 3 deleted! Number Thing ------- ------------ 0 63 1 20 2 34 [A]dd, [D]elete, or [S]ave/quit : d Enter number to delete, or nothing (to cancel): 1 Thing # 1 deleted! Number Thing ------- ------------ 0 63 1 34 [A]dd, [D]elete, or [S]ave/quit : a Enter new Thing, or nothing (to cancel): /tmp/somefile.txt Thing added. Number Thing ------- ------------ 0 63 1 34 2 /tmp/somefile.txt [A]dd, [D]elete, or [S]ave/quit : a Enter new Thing, or nothing (to cancel): internalsite.corp.com Thing added. Number Thing ------- ------------ 0 63 1 34 2 /tmp/somefile.txt 3 internalsite.corp.com [A]dd, [D]elete, or [S]ave/quit : s Things updated! Exiting.
[garyd@dizzymouse iterator]$ ./iterator.py command Mode : Command Command : /tmp/brawl.py _THINGS_ Things : 63 34 /tmp/somefile.txt internalsite.corp.com On run, each thing replaces _THINGS_. Examples: ping -c 1 _THINGS_ cp _THINGS_ /tmp; ls -l /tmp/_THINGS_ New command: echo "Doing _THINGS_..." Save? [Y]es, [N]o, or <enter> for next preview. New command: echo "Doing _THINGS_..." Preview: echo "Doing 63..." Preview: echo "Doing 34..." Preview: echo "Doing /tmp/somefile.txt..." y Configuration updated! Exiting. [garyd@dizzymouse iterator]$ [garyd@dizzymouse iterator]$ ./iterator.py show Mode : Show Command : echo "Doing _THINGS_..." Things : 63 34 /tmp/somefile.txt internalsite.corp.com [garyd@dizzymouse iterator]$ ./iterator.py run Mode : Run Command : echo "Doing _THINGS_..." Doing 63... Doing 34... Doing /tmp/somefile.txt... Doing internalsite.corp.com... Run complete. Exiting.