Skip to content

Instantly share code, notes, and snippets.

@lokori
Forked from woltage/getdomains.sh
Last active September 17, 2018 11:00
Show Gist options
  • Save lokori/53434cc43c464c5d82e692c814a876de to your computer and use it in GitHub Desktop.
Save lokori/53434cc43c464c5d82e692c814a876de to your computer and use it in GitHub Desktop.
Skripti joka hakee Y-tunnuksella kaikki firman omistamat .fi -verkkotunnukset. (alkuperäinen https://gist.github.com/woltage/5b7a744f9562b9348c90c6e0d038d92a)
#!/bin/bash
## Y-Tunnukseen perustuva domainejen haku (.fi)
## Esimerkki: getdomains 1093944-1 # MTV Oy
# Laita tämä .bashrc tai .zshrc
# Käyttöesimerkkejä:
# Looppaa Y-tunnuksetn kaikki domainit läpi ja tee kysely
# for i in $(getdomains 1093944-1); do echo $i && host -t cname www.$i; done
set -eu
if [ "$#" -ne 1 ]; then
echo "Anna parametrina Y-tunnus, jolla haetaan."
fi
echo "Haetaan Y-tunnuksella $1"
function getdomains() {
curl 'https://odata.domain.fi/OpenDomainData.svc/Domains()?$orderby=GrantDate%20desc&$top=500&$filter=OrganizationId%20eq%20%27'$1'%27' -s| grep -oP "<d:Name>\K([a-\
å]+)<"|sed 's/</.fi/g'
}
# Hae domainiin perustuen: domain_getdomains
function domain_getdomains() {
CODE=`whois $1|grep -oP "register number(.*): \K(.*)"`
getdomains $CODE
}
getdomains $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment