I have a command that I want to run against a large number of servers. I have the list of servers, how do I run it against one server at a time? Any help would be appreciated.
for lin in `cat server.lst`
do
echo "Procesing server: $lin"
done
#-- Or --
While read var
do
echo "Procesing server: $var"
done <server.lst
[:eyes]
----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
When running a rsh/ssh loop, I prefer to use the "for ... in" construction. On some 'nixes, the rsh or ssh command eats away at the stdin, and the "while read var" statement is only able to read the first line of its input and hits an EOF after the first rsh or ssh terminates.
Another solution is to provide an empty stdin for the rsh or ssh command line.
so:
for variant:
for svr in `cat $LIST`
do
rsh $svr /what/ever/command
done
while variant:
while read svr
do
rsh $svr /what/ever/command </dev/null
done < $LIST
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.