Hi folks
I've written a script to clear firewall connections. It works fine but occasionally it will error out with the following:
no such item (4)
I think this is due to the way RouterOS is processing the connection list. The script is as follows:
:local ConnectionList [/ ip firewall connection find]
:foreach Connection in=[$ConnectionList] \
do={/ip firewall connection remove $Connection}
I think what is happening is that between storing the connections as an array and then removing them, if a connection closes, the 'remove' command runs against a connection which doesn't exist, which results in the error.
I've tried adding an 'on-error={' condition to this, but I can't get it to work, I always get syntax errors.
Can anyone tell me a way that I can either prevent this error from occurring, or handle the error gracefully?
Thanks