Skip to content

Instantly share code, notes, and snippets.

@aloha1003
Created June 2, 2017 03:04
Show Gist options
  • Save aloha1003/d67b3673d35f082ea507ebcfa06c8892 to your computer and use it in GitHub Desktop.
Save aloha1003/d67b3673d35f082ea507ebcfa06c8892 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "Get Instance: "
fileName="iplist.txt"
privateIPFileName="privateIp.txt"
iplist=$(aws ec2 describe-instances --filters Name=tag:Name,Values=whoscome | jq -r '.Reservations | .[].Instances[0].NetworkInterfaces[0].Association.PublicIp' > $fileName)
privateIp=$(aws ec2 describe-instances --filters Name=tag:Name,Values=whoscome | jq -r '.Reservations | .[].Instances[0].NetworkInterfaces[0].PrivateIpAddress' > $privateIPFileName)
i=1
osascript <<EOF
tell application "iTerm2"
activate
set Shows to paragraphs of (read POSIX file "$fileName")
tell current session of current window
tell application "System Events" to keystroke "t" using command down
end tell
# set x=1
repeat with nextLine in Shows
if length of nextLine is greater than 0 then
tell current session of current window
tell application "System Events" to keystroke "D" using command down
write text "cd ~/.ssh ; ssh -i 'for-whoscome.pem' ec2-user@" & nextLine
# write text "echo " nextLine
# split horizontally with default profile command "ls -l ."
end tell
# do script "ping google.com" in tab 1 of front window
# my makeTab()
# set x=x+1
# copy nextLine to the end of listOfShows
end if
end repeat
end tell
on makeTab()
tell application "System Events" to keystroke "t" using {command down}
delay 0.2
end makeTab
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment