Run shell script on another server using ssh

Hi,

I have 2 servers and i installed ssh2 on both boxes .. so they they can communicate with each other with our password auth ..

now i want to write a scrip on box 1 for running commands and getting out put from the second box

can some one help me out

Thank you in advance

You can accomplish this with simple redirection.

ssh user@host 'exec bash' < shell-script.sh

This will execute the bash shell on the remote host, and feed bash your shell script. You can substitute any shell of choice for bash of course.

You can even leave out the 'exec bash' argument entirely and it will probably still work, but you will get that login's default shell and not necessarily the one you want.