Created
December 31, 2014 09:31
-
-
Save serverwentdown/73b3568abd2af20ae935 to your computer and use it in GitHub Desktop.
Dirty script to connect to a cluster using nmap!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
RUSER="ubuntu" | |
IFS=$'\n' HOSTS=($(nmap -oG - -sn -n 192.168.11.128-254 | grep 'Host: ' | cut -f 2 -d ' ')) | |
WIDTH=$(tput cols) | |
DIV=$#HOSTS | |
SP=$(( $WIDTH / $DIV )) | |
for ip in $HOSTS; do | |
CMD="ssh -i somesshid_rsa $RUSER@$ip" | |
if [[ $HOSTS[1] == $ip ]]; then | |
tmux new-session -d "$CMD" | |
else | |
tmux split-window -h "$CMD" | |
tmux select-pane -L | |
tmux resize-pane -x $SP | |
tmux select-pane -R | |
fi; | |
done | |
tmux a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment