1 line script run on terminal, won't run in "/system script"

This command run on terminal, but I cannot make it to work in “/system script” as a script

:log error [/ip firewall filter get 0 action]

How to convert this command to a script in “/system script”?

Please help

Thanks

You cant use ‘get’ in a script very easily. You should use ‘find’ with ‘get’.

:log error [/ip firewall filter get [/ip firewall filter find comment=“rule1”] action]

Getting closer to the answer anyway

With this command, I can make it work in a script in “/system script”

:log error [/ip firewall filter get *8 action]

the *8 is the ID I want to grab, where on terminal *8 is 0

Is there an easy way to know the ID for a particular entry in a script?

I don’t want to do looping using :foreach, waste CPU too much

Hello changeip,

Thanks so much for the response. Now I know how the ‘get’ and ‘find’ works together :smiley:

The whole script i am creating now, is about to run every 5 seconds. I don’t want to waste looping while I already know the position of the rule/entry.

Does this "/ip firewall filter find comment=“rule1” do looping?

So the idea of what i need is to avoid looping.

Thanks