Quantcast
Channel: MikroTik
Viewing all articles
Browse latest Browse all 15394

Scripting • fetch seems to behave different when called in function

$
0
0
I'm trying to get my feet wet with MikroTik scripts. After having a basic script I'm trying to clean it up a bit and wrap certain parts into functions.

When doing this with the fetch function it seems to behave different:
Code:
# MikroTik script to update the DNS entry when Internet connection has been# established via PPP.## Put this into the PPP profile as script on-up and assign the profile to the # pppoe connection.## Permissions required:#   - read#   - test#:global afraidSyncURL "http://sync.afraid.org/u/random_token/";:local updateDDNS do={    :local result [/tool fetch url=$afraidSyncURL as-value output=user]    :if ($result->"status" = "finished") do={        :log info ("FreeDNS: " . $result->"data");    }}:log info "FreeDNS: IP address update started";:local result [/tool fetch url=$afraidSyncURL as-value output=user]:if ($result->"status" = "finished") do={  :log info ("FreeDNS: " . $result->"data");}$updateDDNS:log info "FreeDNS: Update script finished"
The part
Code:
:local result [/tool fetch url=$afraidSyncURL as-value output=user]:if ($result->"status" = "finished") do={  :log info ("FreeDNS: " . $result->"data");}
runs without issues but when $updateDDNS is called there is an error "failure: Mode not specified", if the mode gets specified the next error appears ("failure: Please provide IP address or host") and so on...
When the variable $afraidSyncURL gets replaced by the actual value within $updateDDNS the script works, but its not clear exactly why.

Why do the two calls behave differently?

Statistics: Posted by MakroTok — Thu Feb 29, 2024 3:07 pm



Viewing all articles
Browse latest Browse all 15394

Trending Articles