Skip to content

Instantly share code, notes, and snippets.

@djw8605
Created March 2, 2012 05:18
Show Gist options
  • Save djw8605/1955877 to your computer and use it in GitHub Desktop.
Save djw8605/1955877 to your computer and use it in GitHub Desktop.
hadoop rack script for each domain.
#!/bin/sh
#value=`nslookup $1 | grep name | awk '{print \$4}'`
echo $@ >> /tmp/rack.out
for ARG in "$@"
do
if [[ "$ARG" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
name=`nslookup $ARG | grep name | awk '{print \$4}'`
site=`expr "$name" : '.*\.\([a-zA-Z0-9]*\.[a-zA-Z0-9]*\).$'`
else
site=`expr "$ARG" : '.*\.\([a-zA-Z0-9]*\.[a-zA-Z0-9]*\)$'`
fi
echo /${site//\./\/}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment