Community discussions

MikroTik App
 
swisstico
just joined
Topic Author
Posts: 19
Joined: Sat Dec 12, 2015 6:10 am
Contact:

Include vars in path

Mon Dec 24, 2018 11:33 pm

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?
 
mistry7
Forum Guru
Forum Guru
Posts: 1480
Joined: Tue Oct 13, 2009 11:57 am
Location: Germany

Re: Include vars in path

Tue Dec 25, 2018 12:28 am

Please show your variable declaration too
 
swisstico
just joined
Topic Author
Posts: 19
Joined: Sat Dec 12, 2015 6:10 am
Contact:

Re: Include vars in path

Tue Dec 25, 2018 2:37 am

# 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)

Who is online

Users browsing this forum: luczsoma, Xaesar and 9 guests