Feature Request: fetch to variable instead of file

Hi,

in my dyndns scripts I’am using fetch to gather my public ip, this information is written to a file on the flash drive.

I’am a little bit concerned that these continuous writes to the flash memory will hurt it over the years, maybe I’am totally wrong on this.

But wouldn’t it be an easy thing to have a fetch option to return the response directly.

Usually its done by something like this:

/tool fetch url="http://automation.whatismyip.com/######.asp" mode=http;
global getIP [/file get ######.asp contents];

To avoid a temporary file a content option for fetch would be great:

global getIP [/tool fetch url="http://automation.whatismyip.com/######.asp" mode=http contents;];

–Michael

http://forum.mikrotik.com/t/dyndns-org-script-now-to-remove-all-log-info/53828/1

See this.

Hi Jarda,

thanks for your reply. For any odd reason I wasn’t even thinking about doing this with a DNS query. But having fetch loading content into variable could still be a handy thing.

If anybody wants to run a self-service for this, it can be easily done with dnsdist from PowerDNS with a few lines of lua:

-- spoof responses in Lua
function spoofMyIP(dq)
	if(dq.qtype==1)
	then
		return DNSAction.Spoof, dq.remoteaddr:toString()
	else
		return DNSAction.None, ""
	end
end

addLuaAction("myip.mydomain.de.", spoofMyIP)

–Michael

Solution by as-value: “Get_file_content_received_by_fetch_tool”
https://wiki.mikrotik.com/wiki/Manual:Scripting_Tips_and_Tricks#Get_file_content_received_by_fetch_tool
example by check MAC Vendor:

:put ([/tool fetch url=("https://api.macvendors.com/"."D4:CA:6D:00:01:02") output=user as-value ]->"data")

Output:

Routerboard.com

Hi,

thanks for bringing this up again, since 6.43 it’s possible to fetch into variables which is great.

Sometimes it takes a while, but at the end Mikrotik delivers, IMHO.

–Michael