Skip to content

Instantly share code, notes, and snippets.

@TrevorBasinger
Created February 10, 2016 17:55
Show Gist options
  • Save TrevorBasinger/188114f1aa91d37729d8 to your computer and use it in GitHub Desktop.
Save TrevorBasinger/188114f1aa91d37729d8 to your computer and use it in GitHub Desktop.
#!/bin/bash
SESSION="slaveSSH"
defaultwindow=1
defaultpane=1
regex=${1:-'10.0'}
shift
tmux kill-session -t $SESSION 2> /dev/null
tmux has-session -t $SESSION 2> /dev/null
if [ $? -ne 0 ]; then
tmux new-session -s $SESSION -n ssh -d
cnt=$defaultpane
for ip in `cron-addresses | jq -r '.[]' | grep -v null | grep $regex`; do
tmux send-keys -t $SESSION:$defaultwindow.$cnt "ssh -i ~/.ssh/FlogistixPoll.pem -oStrictHostKeyChecking=no ec2-user@$ip" C-m
if [ -n "$@" ]; then
tmux send-keys -t $SESSION:$defaultwindow.$cnt "$@" C-m
fi
#while read line
#do
# tmux send-keys -t $SESSION:$defaultwindow.$cnt "$line" C-m
#done < "${1:-/dev/stdin}"
tmux split-window -v
((cnt++))
tmux select-layout tiled
done
tmux kill-pane
tmux select-layout tiled
tmux attach-session -t $SESSION -d 2> /dev/null
if [[ $? -ne 0 ]]; then
echo "Couldn't establish session"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment