Automatic execution of commands in multiple servers using single script.

Hi,

I've to do a simple job many times whenever it has been asked, just i've to log in to all of fourtien HP servers and i've to execute
ps -fu user > temp
cat temp|sendmail "xyz@z.com"
commands to send the statics of all of 14 servers over the mail to particular user id..

Though logging into each and every server and issuing same command is easy, but its time wasting.

Instead of that i want to create a script and run in single server, so that it can fetch statistics from all servers automatically and sends a single mail.
I've started writing script using SSH command but stuck and couldnt proceed.

please guide me in this regard

Thanks

for node in host1 host2 host3
do
  ssh {$node} 'ps -fu user | sendmail xyz@z.com'
done 

start with that - it assumes you have setup ssh keys for each node. And you are not doing this as root.

hi thanks for the reply,

I tested the "for loop" for the two servers, server1 and server2
But its giving the foloowing error
ssh: {server1}: Name or service not known
ssh: {server2}: Name or service not known

Please help in this regard, also i want all the userid and password required for the servers to be hardcoded, ie it shouldnt prompt for password or username

Thanks

No (or not configured...) sendmail on those 2 servers perhaps?

sendmail is working in all of the servers i'm using..
Please check my very first post in this thread. i believe i've explained my problem clearly.

Please help me . i'm still messed in ssh..