From d280e4ad6d8b1b0f16e1de8d0f87abf6bf84ff2f Mon Sep 17 00:00:00 2001 From: David Kerr Date: Sun, 29 Jan 2017 15:09:08 -0500 Subject: [PATCH] Remove use of rev command... new method of separating top domain from subdomain. --- dnsapi/dns_freedns.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dnsapi/dns_freedns.sh b/dnsapi/dns_freedns.sh index 99541def..abc3a3a6 100755 --- a/dnsapi/dns_freedns.sh +++ b/dnsapi/dns_freedns.sh @@ -44,6 +44,13 @@ dns_freedns_add() { _saveaccountconf FREEDNS_COOKIE "$FREEDNS_COOKIE" + # split our full domain name into two parts... + i="$(echo "$fulldomain" | tr '.' ' ' | wc -w)" + i="$(_math "$i" - 1)" + top_domain="$(echo "$fulldomain" | cut -d. -f "$i"-100)" + i="$(_math "$i" - 1)" + sub_domain="$(echo "$fulldomain" | cut -d. -f -"$i")" + htmlpage="$(_freedns_retrieve_subdomain_page "$FREEDNS_COOKIE")" if [ "$?" != "0" ]; then if [ "$using_cached_cookies" = "true" ]; then @@ -53,10 +60,6 @@ dns_freedns_add() { return 1 fi - # split our full domain name into two parts... - top_domain="$(echo "$fulldomain" | rev | cut -d. -f -2 | rev)" - sub_domain="$(echo "$fulldomain" | rev | cut -d. -f 3- | rev)" - # Now convert the tables in the HTML to CSV. This litte gem from # http://stackoverflow.com/questions/1403087/how-can-i-convert-an-html-table-to-csv subdomain_csv="$(echo "$htmlpage" \