Page 1 of 1

Include vars in path

Posted: Mon Dec 24, 2018 11:33 pm
by swisstico
Hello everyone,

We are making a script to configure our MikroTik's firewalls, but we have an issue including vars within the path.
Our firewalls filters are pretty the same for IPv4 and IPv6, only address lists are different.

So we don't want to make a script for each and it look an useless if/else to select the path, so we are looking if it is possible to add a var into the path.

Example
/ip firewall filter print
/ipv6 firewall filter print
have only difference of /ip | /ipv6

We were looking to do something like that:
/$ipVersion firewall filter print
But it doesn't work...

Is possible to do that with scripts?

Re: Include vars in path

Posted: Tue Dec 25, 2018 12:28 am
by mistry7
Please show your variable declaration too

Re: Include vars in path

Posted: Tue Dec 25, 2018 2:37 am
by swisstico
# Script

# ip for IPv4 | ipv6 for IPv6
:global ipVersion ip

/$ipVersion firewall filter print
Result: expected command name (line 1 column 2)
# Script

# ip for IPv4 | ipv6 for IPv6
:global ipVersion ip
:return ("/$ipVersion firewall filter print")
Result: /ip firewall filter print
(Show the command line but don't show the RESULT of the command line)