Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. #
  3. # Usage:
  4. # ./find-records-by-answer.sh <api_key> <answer>
  5. #
  6. # Given an API key and an answer, prints all the records in an account which
  7. # contain that answer.
  8.  
  9. if [ $# -ne 2 ]; then
  10. echo "Usage: "
  11. echo " ./find-records-by-answer.sh <api_key> <answer>"
  12. exit 1
  13. fi
  14.  
  15. API_KEY=$1
  16. ANSWER=$2
  17.  
  18. ZONES=$(curl -s -H "X-NSONE-Key: $API_KEY" "https://api.nsone.net/v1/zones" | jq -r '.[].zone')
  19. for zone in $ZONES; do
  20. 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"
  21. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement