Code Monkey home page Code Monkey logo

iterator's Introduction

iterator

Self-contained, Python-based general-purpose iterator experiment.

Iterator iterates a list of "things" and runs one or more arbitrary system commands on each.

Here's why it's cool: It has a built-in configuration interface, and stores the config within itself. Pretty crazy huh.

# Example run

# Demonstration of "iterator.py" sample script
# A self-contained general-purpose "Thing Doer"
# See script source for details.
# Gary Arthur Douglas Jr | [email protected]

[garyd@dizzymouse iterator]$ ./iterator typohere
./iterator: Invalid mode Typohere

# iterator: Run a command on a list of things
# Usage:
#   iterator show    - Show config
#   iterator things  - Edit list of things
#   iterator command - Edit command
#   iterator run     - Execute current config
#   iterator help    - You are reading it

[garyd@dizzymouse iterator]$ ./iterator show

Mode	: Show
Command	: /tmp/brawl _THINGS_
Things	: 21 63 20 34 85 

[garyd@dizzymouse iterator]$ ./iterator 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 command

Mode	: Command
Command	: /tmp/brawl _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]$ ./iterator show

Mode	: Show
Command	: echo "Doing _THINGS_..."
Things	: 63 34 /tmp/somefile.txt internalsite.corp.com 

[garyd@dizzymouse iterator]$ ./iterator run

Mode	: Run
Command : echo "Doing _THINGS_..."

Doing 63...
Doing 34...
Doing /tmp/somefile.txt...
Doing internalsite.corp.com...

Run complete. Exiting.

[garyd@dizzymouse iterator]$

iterator's People

Contributors

diemastermonkey avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.