Community discussions

MikroTik App
 
BWC
newbie
Topic Author
Posts: 34
Joined: Tue Mar 21, 2006 5:36 pm
Location: Würzburg, Germany
Contact:

Feature Request: fetch to variable instead of file

Sun Jun 05, 2016 11:22 am

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
 
jarda
Forum Guru
Forum Guru
Posts: 7756
Joined: Mon Oct 22, 2012 4:46 pm

Re: Feature Request: fetch to variable instead of file

Fri Aug 05, 2016 4:11 pm

 
BWC
newbie
Topic Author
Posts: 34
Joined: Tue Mar 21, 2006 5:36 pm
Location: Würzburg, Germany
Contact:

Re: Feature Request: fetch to variable instead of file

Sat Aug 06, 2016 1:39 pm

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
 
User avatar
SiB
Forum Guru
Forum Guru
Posts: 1888
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: Feature Request: fetch to variable instead of file

Fri Dec 14, 2018 12:14 pm

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
 
BWC
newbie
Topic Author
Posts: 34
Joined: Tue Mar 21, 2006 5:36 pm
Location: Würzburg, Germany
Contact:

Re: Feature Request: fetch to variable instead of file

Fri Dec 14, 2018 12:18 pm

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

Who is online

Users browsing this forum: Bing [Bot], Gianna99 and 106 guests