Page 1 of 1

Feature Request: fetch to variable instead of file

Posted: Sun Jun 05, 2016 11:22 am
by BWC
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

Re: Feature Request: fetch to variable instead of file

Posted: Fri Aug 05, 2016 4:11 pm
by jarda

Re: Feature Request: fetch to variable instead of file

Posted: Sat Aug 06, 2016 1:39 pm
by BWC
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

Re: Feature Request: fetch to variable instead of file

Posted: Fri Dec 14, 2018 12:14 pm
by SiB
Solution by as-value: "Get_file_content_received_by_fetch_tool"
https://wiki.mikrotik.com/wiki/Manual:S ... 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

Re: Feature Request: fetch to variable instead of file

Posted: Fri Dec 14, 2018 12:18 pm
by BWC
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