Skip to content

Instantly share code, notes, and snippets.

@travis-g
Created May 20, 2016 16:55
Show Gist options
  • Save travis-g/44f45cce68659406323d25a9356d891f to your computer and use it in GitHub Desktop.
Save travis-g/44f45cce68659406323d25a9356d891f to your computer and use it in GitHub Desktop.
Script for http://ifconfig.me
#!/bin/sh
#
# Script for http://ifconfig.me
usage () {
cat <<EOF
usage: $(basename $0) [-ahinpu]
-a return all available info
-h show help
-i return external IP address (default)
-n return remote host name
-p return port number
-u return user agent
EOF
}
test "$1" = "-h" && usage && exit 0
case $1 in
-a) cmd=all ;;
-n) cmd=host ;;
-p) cmd=port ;;
-u) cmd=ua ;;
*) cmd=ip ;;
esac
curl ifconfig.me/$cmd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment