Community discussions

MikroTik App
 
relam
just joined
Topic Author
Posts: 8
Joined: Thu Nov 07, 2013 1:48 pm

Manage script errors in rsc file

Mon Feb 17, 2014 2:49 pm

Hi,

I'm trying to handle errors in mikrotik scripts, and I have found the command do/ on-error in the wiki, as it follows:

:do {
:put [:resolve www.example.com];
} on-error={ :put "resolver failed"};


I have done my code and tested copying and pasting in the console and it works, but when I put in an .rsc file and I execute it with the import command, it doesn't work. I get the message "Script file loaded and executed successfully", but I know that it is not true because the script has not done what it should have done.

Does anyone how to handle errors in an rsc file using this command? (My version of routeros is 6.9 and the architecture is mipsbe)

Thank you very much!
 
User avatar
skot
Long time Member
Long time Member
Posts: 584
Joined: Wed Nov 30, 2011 3:05 am

Re: Manage script errors in rsc file

Thu Feb 20, 2014 7:04 pm

Hm... the example script seems to work for me (on v6.10), either by copy/paste or by /import.

With bad url:
[admin@MikroTik] > /import test.rsc 
resolver failed

Script file loaded and executed successfully
With good url:
[admin@MikroTik] > /import test.rsc 
93.184.216.119

Script file loaded and executed successfully
[admin@MikroTik] >
What does your script look like?
 
relam
just joined
Topic Author
Posts: 8
Joined: Thu Nov 07, 2013 1:48 pm

Re: Manage script errors in rsc file

Tue Feb 25, 2014 3:10 pm

Thanks for your reply!

I have noticed that there was a syntax error, it worked in terminal but not in an script. Now I have corrected and it works fine!

Thank you