Page 1 of 1

Manage script errors in rsc file

Posted: Mon Feb 17, 2014 2:49 pm
by relam
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!

Re: Manage script errors in rsc file

Posted: Thu Feb 20, 2014 7:04 pm
by skot
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?

Re: Manage script errors in rsc file

Posted: Tue Feb 25, 2014 3:10 pm
by relam
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