Doing a quick
for i in `seq 1 15`; do ssh www$i.website.com "reboot"; done
is VERY convenient. It's fast, quick to write, and extends existing shell knowledge.This would be very useful in all sorts of sysadmin places.
Imaging that I wrote a quick server, in Python/Rails/Node/whathaveyou, that accepted input, then returned a formatted JSON array with server info.
Now, I can do
$SERVERLIST = `curl http://my-server/list-of-servers`
for i in ```$SERVERLIST.webservers.list()```; do ssh $i "reboot"; done
for i in ```$SERVERLIST.dbservers.list()```; do ssh $i "uptime" >> serverload.txt; doneThat's one of my "favourite" examples of using scripting where it's not needed. Have a look at what's actually keeping critical systems working -> inittab, supervisord, etc. Lately upstart also migrated from scripts to something more declarative.
Edit: forgot the bit where everyone "parses" the output of commands like `ifconfig` and pretends they will never change, or will never fail, or will return the information in the same format. How many scripts relied on grepping ifconfig output for "inet" before "inet6" broke the startup?
Since it's tracking on HN, I'll also point this out: http://www.leancrew.com/all-this/2011/12/more-shell-less-egg...
my @allfiles = `ls /somedir/`; for my $file (@allfiles) { chomp $file; ... }
Is a wonderful thing. It's not pretty Perl, but it's still better than Bash, IMO.
my @allfiles = glob '/somedir/*';
Now you properly report errors and you don't have to chomp.I agree! If you do this a lot then you might be interested in GNU parallel. It's super handy!
seq 1 15 | parallel ssh www{}.website.com reboot
http://www.gnu.org/s/parallel/Each tool has a purpose -- I don't think mucking around with json is particularly suitable for bash...