Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- #
- # Usage:
- # ./find-records-by-answer.sh <api_key> <answer>
- #
- # Given an API key and an answer, prints all the records in an account which
- # contain that answer.
- if [ $# -ne 2 ]; then
- echo "Usage: "
- echo " ./find-records-by-answer.sh <api_key> <answer>"
- exit 1
- fi
- API_KEY=$1
- ANSWER=$2
- ZONES=$(curl -s -H "X-NSONE-Key: $API_KEY" "https://api.nsone.net/v1/zones" | jq -r '.[].zone')
- for zone in $ZONES; do
- curl -s -H "X-NSONE-Key: $API_KEY" "https://api.nsone.net/v1/zones/$zone" | jq -r '.records[] | .domain + "/" + .type + ": " + .short_answers[]' | grep -E ": $ANSWER"
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement