Created
November 13, 2019 20:43
-
-
Save ramann/ab6cdc49c56c66b7c1c5bf4397de4dbc to your computer and use it in GitHub Desktop.
resolve list of names
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 | |
# because Qualys vm can only take names!?! | |
# usage: ./resolve.sh filename nameserver(optional) | |
for i in `cat $1`; | |
do | |
answer=$(nslookup $i $2) | |
resp_code=$(echo $?) | |
if [ $resp_code -eq "0" ] | |
then | |
name=$(echo "$answer" | grep ^Name | head -n1 | awk '{print $2}') | |
# ip=$(echo "$answer" | grep -A10 answer | grep Address | head -n1 | awk '{print $2}') | |
ip=$(echo "$answer" | grep -A10 ^Name | grep Address | head -n1 | awk '{print $2}') | |
echo "$i,$name,$ip" | |
else | |
echo "$i,," | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment