Community discussions

MikroTik App
mknnoc
教练
教练
Topic Author
Posts: 229
加入: 2008年2月28日星期四6:40 am
Location:cambodia

Is it possible to have a catch of command execution?

Wed Oct 06, 2010 9:28 am

let say we execute a command "/ip firewall address-list add list=abc address=1.0.0.1" from a script.
if this execution failed, the script will :put "Failed" else :put "Success".

Is it possible to catch ?
Top
用户头像
mrz
MikroTik Support
MikroTik Support
Posts: 6944
加入: Wed Feb 07, 2007 12:45 pm
Location:Latvia
Contact:

Re: Is it possible to have a catch of command execution?

Wed Oct 06, 2010 9:43 am

Currently there is no built in catch .

To verify if entry is added use "find" command, to search for specific entry.
Top
dssmiktik
Forum Veteran
Forum Veteran
Posts: 732
加入: Fri Aug 17, 2007 8:42 am

Re: Is it possible to have a catch of command execution?

Fri Oct 08, 2010 4:30 am

Here's a workaround that I've found for general execution:
Code:Select all
:global RetCode; :execute (":global RetCode;" . \ "/ip firewall address-list add ;" . \ ":set RetCode 1;") :local wait 5; :set RetCode 0; :while ($RetCode = 0 && $wait > 0) do={ :set wait ($wait - 1); :delay 1; } :if ($RetCode = 1) do={ :put "Command executed successfully" } else={ :if ($wait = 0) do={ :put "Command timed out" } else={ :put "Command failed" } }
Once you do this a few times, you get the hang of it.
Top
blake
Member
Member
Posts: 426
加入: Mon May 31, 2010 10:46 pm
Location:Arizona

Re: Is it possible to have a catch of command execution?

Wed Dec 22, 2010 11:34 pm

Currently there is no built in catch.
Is there any timeframe on the implementation of this? Back you 2009you mentionedthis feature would be added in later releases.
Top
blake
Member
Member
Posts: 426
加入: Mon May 31, 2010 10:46 pm
Location:Arizona

Re: Is it possible to have a catch of command execution?

Wed Dec 22, 2010 11:34 pm

Currently there is no built in catch.
Is there any timeframe on the implementation of this? Back you 2009you mentionedthis feature would be added in later releases.
Top

Who is online

Users browsing this forum: No registered users and 16 guests