Last active
September 9, 2016 11:30
-
-
Save ajmazurie/5212be25bdd1cead8f9b to your computer and use it in GitHub Desktop.
Retrieve the hostname from an existing StarCluster cluster on the command-line
This file contains 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/bash | |
if [[ $# != 1 ]]; then | |
echo "ERROR: a cluster name must be provided" 1>&2 | |
exit 1 | |
fi | |
cluster_meta="$(starcluster listclusters $1 2>&1)" | |
if [[ $? != 0 ]]; then | |
echo "ERROR: unable to find information about cluster '$1'" 1>&2 | |
msg=$(echo "${cluster_meta}" | nl -b n -w 1 -s '| ') | |
echo -e "Message was:\n$msg" 1>&2 | |
exit 1 | |
fi | |
echo "${cluster_meta}" | grep "master running" | sed -e 's/.*master.*\(ec2-.*\)/\1/g' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixed a typo on line 17 that would otherwise merge the starcluster output into a single line