Community discussions

 
SurferTim
Forum Guru
Forum Guru
Topic Author
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

script /file and :resolve return values (/file solved)

Thu Jan 29, 2009 12:22 pm

Greetings!

Maybe it is just me, but the /file commands are not returning to the script (EDIT: on fail only). Is there a way I can get a return value instead of the script aborting?

Same with script command ":resolve" on V3.X. OK on success. Aborts script on fail. Several of us need a return value on fail. I did not even realize it was failing until someone else on the forum brought it to my attention.

UPDATE: I found the reason my scripts with /file commands were failing. You cannot embed the /file get and find commands. You must use the 'find' parameter assigned to a variable, then check it. If it is valid, then you can use that variable in other file commands. If you use this
:global filecontents [/file get [/file find name=test.txt] contents]
and the file does not exist, then the script will abort.

With this
:global files [/file find name=test.txt]
:if ([:len $files] > 0) do={
   :global filecontents [/file get $files contents]
} else={
   :log info "failed"
}
it seems to do ok.

:resolve still a problem
 
changeip
Forum Guru
Forum Guru
Posts: 3803
Joined: Fri May 28, 2004 5:22 pm

Re: script /file and :resolve return values (/file solved)

Thu Jan 29, 2009 6:32 pm

I suggest sending support a ticket on this one. I wouldn't call it a bug, but it would sure prevent some in the future : )
Colo and Wholesale Bandwidth Available! Sales at SanDiegoBroadband dot com
 
SurferTim
Forum Guru
Forum Guru
Topic Author
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: script /file and :resolve return values (/file solved)

Sun Feb 01, 2009 3:01 pm

I would call it a bug. Doesn't really need a ticket from me. Someone else has sent one. Run this
:put [:resolve bad.yahoo.com]; :log info "Got to here"
If you see "Got to here" in your log, let me know.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 5886
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: script /file and :resolve return values (/file solved)

Mon Feb 02, 2009 12:45 pm

The problem is that resolve returns generic error and script thinks that it encountered an error and stops.
In one of next versions we will add ability to catch those errors similar to try-catch.
 
SurferTim
Forum Guru
Forum Guru
Topic Author
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: script /file and :resolve return values (/file solved)

Tue Feb 03, 2009 1:13 pm

OK with me. I can make do until fixed.

This "generic error", is it being returned from the dns resolver to the script interpreter? Could that affect other dns calls to the resolver also? That is presuming there is only one routine that resolves dns in the OS, correct?

Who is online

Users browsing this forum: No registered users and 11 guests