Community discussions

MikroTik App

Search found 3 matches

by DaleNicholsSTG
Fri Aug 03, 2018 2:32 am
Forum: Scripting
Topic: script stop on error
Replies: 6
Views: 12674

Re: script stop on error

:do has an on-error feature. This should work:
:foreach i in=[/ip firewall address-list find ] do={
  :if ( [/ip firewall address-list get $i comment] = "IPblacklist1" ) do={
    :do {
      /ip firewall address-list remove $i
    } on-error={}
  }
}
by DaleNicholsSTG
Fri Aug 03, 2018 2:28 am
Forum: Scripting
Topic: Commands run perfect in terminal, run perfectly as a script. But refuse to run as a .rsc startup script. [SOLVED]
Replies: 2
Views: 10758

Re: Commands run perfect in terminal, run perfectly as a script. But refuse to run as a .rsc startup script. [SOLVED]

First of all, code is easier to read when it is in a code block. I think your code is: :if ([/system resource get board-name] = "RB750GL" ) do={ :do { certificate import file-name=AddTrustExternalCARoot.CRT passphrase="" }\ on-error={ certificate import file-name=AddTrustExternal...
by DaleNicholsSTG
Fri Aug 03, 2018 2:02 am
Forum: Scripting
Topic: Functions and function parameters
Replies: 69
Views: 139731

Re: Functions and function parameters

You will never be able to access local variables (defined outside function) inside function. For that use global variables. You can do it if you use the older [:parse] functionality. I wanted a function to do some debug logging of a script, but only when I needed it. Notice the line where I set log...