$ for S in `cat file_of_target_addrs` > do > ssh $S '/path/to/command/to/that.sh' > done $ (assuming your shell supports for loops, sub with local syntax as needed)