Community discussions

MikroTik App
 
oldunixguy
just joined
Topic Author
Posts: 9
Joined: Wed Sep 06, 2017 10:27 am

routeros 6.42.5 and 6.42.6 script /file not working

Fri Jul 13, 2018 6:27 am

routeros 6.42.5 and 6.42.6 script /file not working as expected.
the device is RB450Gx4

This code:
:local ddnshost "google.com"
:log info "Hostname = $ddnshost"
:local ddnsip [:resolve $ddnshost]
:log info "IP = $ddnsip"
/tool fetch mode=https address=[:resolve ifconfig.co] port=443 host="ifconfig.co" \
src-path="/ip" dst-path="/currentip.txt"
:log info "got here"
:local currentdnsip [/file get "currentip.txt" contents]
:log info "currentip.txt = $currentdnsip"
--------------------------
Upon the first running the output in the LOG ends with "got here".
Yet, the file was created and the contents are correct.

If I remove that file and rerun the script the results are the SAME.

If I do NOT remove the file and then rerun the script the output does include the info entry with "currentip.txt = ...." with the correct result.

I have run this a zillion times and the two alternatives always produce the same inconsistent results.
What is wrong here?

Thanks for any help!
oldunixguy
 
User avatar
dasiu
Trainer
Trainer
Posts: 231
Joined: Fri Jan 30, 2009 11:41 am
Location: Reading, UK
Contact:

Re: routeros 6.42.5 and 6.42.6 script /file not working

Fri Jul 13, 2018 11:30 am

What is wrong here?
After the fetch, but before reading the file, put a short delay, like 2 seconds:
:delay 2s;
Unfortunately, this is how it works - the file that has just been downloaded/created locally - is not visible immediately, though the fetch command already finished its job. This is MikroTik's internal issue (maybe some disk buffering) - known issue and known solution.
 
oldunixguy
just joined
Topic Author
Posts: 9
Joined: Wed Sep 06, 2017 10:27 am

Re: routeros 6.42.5 and 6.42.6 script /file not working

Fri Jul 13, 2018 8:50 pm

Thanks!

Wouldn't it be wise to add this "workaround" to the manuals, guides, howots, etc. spread all around the internet? I didn't see this workaround and thus fell into the bug.

How long has this been a problem?

Thanks for the advice!
oldunixguy

Who is online

Users browsing this forum: vazquez and 24 guests