This is surely the most elaborate excuse ever for not writing those maintenance scripts?
for h in host1 host2 host3; do \
echo -e "\n$h\n===========\n"; \
ssh $h 'ln -s /some/path /path/to/link && ls -l /path/to/link'; \
done
edit: woops, left out a couple semicolons...Exactly.
One-offs are easy to test interactively with cssh, and despite what anyone thinks, there are always one-offs in the real world.
In short, use automation with care.
Thank you for this comment, I never knew you could pass commands to ssh.
Example:
dsh -Mg all-machines -F 20 'do something'
-M: Prepend any line of output with the machine that emitted it
-g: runs the group all-machines (just a text file in etc/dsh/group)
-F 20: forks at most 20 copies of ssh in the background so you don't overload the server you're running this from
for i in `seq 1 30`; do \
echo -e "\nhost$i\n===========\n"; \
ssh host$i 'ln -s /some/path /path/to/link && ls -l /path/to/link'; \
done
Also, if you just start typing for i in `seq 1 30`
do
commands
more commands
done
On the command line itself, you don't need to worry about semicolons. Bash will take care of it. for i in {1..30}; do...Good point about not needing semicolons for multiple-line stuff (assuming the EOL's are not escaped, as you have it in your example). I blame the PHP I spent all week immersed in...bleh.