Technology, blah

Why I love Bash

1 Comment

Bash is my go-to language for busting out sysadmin stuff. I’ve been ramping up with python for a while now, and for more complicated tasks, it’s fantastic; it should probably even be fantastic for simple tasks. But, there is one thing that I do all of the time in Bash that I have yet to find a way to replicate without unnecessary complexity in python:

agregateResults (); { while read line; do echo "Program Output: $line"; done; }
clientCode (); { echo "I am client $(hostname)."; }
if [[ "${1}" == "client" ]]; then
for server in ${*}; do
cat ${0} | ssh ${server} -s client
done | agregateResults

This is so freaking useful. I have servers across multiple domains and I need to run script to aggregate data from all of them, but I can’t always count on network file systems being available, etc. This lets me have a script in once place and execute the same code everywhere without fumbling with copying it ahead of time, etc. It’s so clean and easy.

When I try to find out how to do this with Python, I read all kinds of stuff about parallels, Paramiko, blah blah blah… it’s all so complicated. There has to be a five-liner example out there somewhere of how to do the same kind of thing.

Started a code-golf at stackexchange for this one: http://codegolf.stackexchange.com/questions/20008/self-execute-over-ssh


One thought on “Why I love Bash

  1. I am always thought about this, thanks for putting up.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s