Toolchest for Python shell scripters

Banish growing bash scripts

Alexander Hultnér
Jun 14, 2017 · 2 min read
Image for post
Image for post
The code in the picture is unrelated to the article

Every once in a while we end up with a shell-script that’s grown out of it’s suit. At this point we need some tools to transition it into a language such as Python. Therefor I’ve collected a small set of tools for achieving these results.

The personal favourite

A personal favourite of mine is sh, I’ve used it several times and is very happy with it.

For the docker pirate

ShutIt focuses on docker (container) build. In addition to their own extensive documentation there’s also a great tutorial on how to build shell scripts in python with ShutIt over at Learn x in y Minutes.

For the make hacker

Tony Narlock (author of The Tao of tmux) describes invoke to me as “Invoke wraps subprocess commands into Makefile-like tasks”, I think that sums it up the purpose perfectly.

Following that advice Mr Narlock also recommended Fabric “Same as invoke, but catered to remote subprocess commands over SSH”, do check it out if you’re going to work with remote servers.

And when you’re at it don’t forget to checkout his libvcs tool which enables easy git (and other vcs systems) automation via python.

Not enough?

Don’t worry I added two great guides on python shell scripting and as a bonus I threw in a fun CLI UI library.

Image for post
Image for post
Example of a graph ui built with urwid

http://nvie.com/posts/writing-a-cli-in-python-in-under-60-seconds/

https://python-guide-pt-br.readthedocs.io/en/latest/scenarios/cli/

https://urwid.readthedocs.io/en/latest/

Hultnér

Product Development in the connected world

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store