Skip to content

Instantly share code, notes, and snippets.

@ajmazurie
Last active September 9, 2016 11:30
Show Gist options
  • Save ajmazurie/5212be25bdd1cead8f9b to your computer and use it in GitHub Desktop.
Save ajmazurie/5212be25bdd1cead8f9b to your computer and use it in GitHub Desktop.
Retrieve the hostname from an existing StarCluster cluster on the command-line
#!/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'
@ajmazurie
Copy link
Author

Fixed a typo on line 17 that would otherwise merge the starcluster output into a single line

@dkoppstein
Copy link

Thanks for writing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment