Skip to content

Commit

Permalink
Resolved: ./godaddyDDNS.sh: line 42: [: []: integer expression expected
Browse files Browse the repository at this point in the history
  • Loading branch information
navilg committed Jul 6, 2020
1 parent 5e718e5 commit 7dc3c69
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions godaddyDDNS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ result=$(curl -s -X GET -H "$headers" \

dnsIp=$(echo $result | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
existingTtl=$(echo $result | cut -d "," -f 3 | cut -d ":" -f 2)
# If record is not created ttl value to initialise with a number
[[ "$existingTtl" == "[]" ]] && existingTtl=0

# Get public ip address there are several websites that can do this.
ret=$(curl -s GET "http://ipinfo.io/json")
Expand All @@ -48,8 +50,8 @@ currentIp=$(echo $ret | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
-H "Content-Type: application/json" \
-d [$request] "https://api.godaddy.com/v1/domains/$domain/records/A/$name")
# Fetch out status from output and REMOVES \r character which is automatically getting suffixed in output of API
result=$(echo "$nresult" | grep -i http | awk '{first=$1;$1="";print $0;first;}' | awk '{print $NF}'|sed 's/\r$//')
#res=$(echo $result|awk '{print $NF}'|sed 's/\r$//')
result=$(echo "$nresult" | grep -i http | awk '{first=$1;$1="";print $0;first;}')
res=$(echo $result|awk '{print $NF}'|sed 's/\r$//')
if [[ "$res" == "OK" ]]
then
# If status of returned output is OK
Expand Down

0 comments on commit 7dc3c69

Please sign in to comment.