I need to loop through and ssh to multiple hosts and run a series of commands on each.
for i in $(jot -w '%02.0f' 14 1) >do ssh user@host$i sudo -i "command1; command2; command3" >done
but I can't get it to work correctly. I've seen various things on The Google like
sudo sh -c, piping to sudo, etc, but can't figure it out.
- I'm ssh'ing as a regular user that can sudo with no password (ssh as root not enabled)
- command1 not returning 0 should not prevent command2 from running, etc, hence
- I'm running the loop from a mac, hence
jot -w, which is roughly equivalent to
seq -fin linux
- ssh'ing to CentOS 5.4
- I'd like it to run with root's $PATH so I don't have to specify the full path to the commands, but it's not totally necessary
thanks in advance!