Community discussions

MikroTik App
 
dualB
just joined
Topic Author
Posts: 13
Joined: Sun May 17, 2020 11:22 am

Script fails

Mon Sep 20, 2021 1:05 am

hapac2 6.48.1

I've taken scripts from this forum to update ddns. I've checked that the ddns url works from a browser in the following format
https://dynamicdns.park-your-domain.com ... p=[your_ip]

:
local password "thesecretkey1234"
:local subdomain "@"
:local domainn "mydomain.com"
:log info "Start DDNS $subdomain $domainn"
:local currentIP [/ip address get [:pick [/ip address find interface="SSEbb"] 0] address]
:log info "WAN IP:$currentIP"
:local url1 "https://dynamicdns.park-your-domain.com/update\3Fhost=$subdomain&domain=$domainn&password=$password&ip=$currentIP"
/tool fetch url=($url1) mode=https
:log info "DNS Successfully Updated"
The script appears to execute to line 4 as that is printed to the log.
From the terminal I've executed the get ip address and it does return the correct address/interface.

Aside from the above, if I execute the below line from terminal and then log/put the var it returns a blank string.
:local currentIP [/ip address get [:pick [/ip address find interface="SSEbb"] 0] address]
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Script fails

Mon Sep 20, 2021 10:28 am

If SSEbb interface exist, and have at least one IP:
{
:local password  "thesecretkey1234"
:local subdomain "@"
:local domainn   "mydomain.com"
/ip address
:local arrayofID [find where interface="SSEbb"]
:local firstID   [:pick $arrayofID 0]
:local fulladdr  [get $firstID address]
:local address   [:pick $fulladdr 0 [:find $fulladdr "/" -1]]

:log info "Start DDNS $subdomain $domainn - WAN IP: $address"
/tool fetch url="https://dynamicdns.park-your-domain.com/update\3Fhost=$subdomain&domain=$domainn&password=$password&ip=$address"
:log info "DNS Successfully Updated"
}
 
dualB
just joined
Topic Author
Posts: 13
Joined: Sun May 17, 2020 11:22 am

Re: Script fails

Wed Sep 22, 2021 12:20 am

Excellent! Thank you that does the job nicely.

Who is online

Users browsing this forum: JDF and 17 guests