[SLUG] better way to consolidate shell commands

From: Mike Branda (mike@wackyworld.tv)
Date: Thu Aug 19 2004 - 15:10:15 EDT


hey all....

I've been taking advantage of the shared rsa key that Ian set me up with
a while back for our 122 render nodes that allows me to ssh without a
pwd to those specific machines. The next step was to create a couple of
anyscript.sh shell scripts that basically do a given command on all of
them. for example ( and I know this is very basic so try not to laugh
too hard.....) -

#! /bin/sh

echo "attempting to ssh 192.168.3.2 as root"
ssh root@192.168.3.2 "df -h"
echo "attempting to ssh 192.168.3.3 as root"
ssh root@192.168.3.3 "df -h"
echo "attempting to ssh 192.168.3.4 as root"
ssh root@192.168.3.4 "df -h"
echo "attempting to ssh 192.168.3.5 as root"
ssh root@192.168.3.5 "df -h"
echo "attempting to ssh 192.168.3.6 as root"
ssh root@192.168.3.6 "df -h"
echo "attempting to ssh 192.168.3.7 as root"
ssh root@192.168.3.7 "df -h"
echo "attempting to ssh 192.168.3.8 as root"
ssh root@192.168.3.8 "df -h"

and so on all the way through .123 at the end. If I want to see
something else I just do a search and replace of whatever is in quotes.
While this gets the job done, I know that this way is not very efficient
and it will get worse as more nodes are added. In an effort to learn
more, can anybody tell me if there's a way to add a variable that
increases by a factor of 1 until it reaches a certain number (say
.123)?? If this could be done, I could just change the stop point for
the variable. In addition to this does anybody know where any good web
tutorials are for sh and bash scripting basics??

thanks!!

Mike Branda Jr.

-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 15:00:24 EDT