mirror of
https://github.com/wifinigel/MikrotikScripting.git
synced 2025-12-14 14:39:30 +00:00
update for v6/v7 support
This commit is contained in:
parent
4871e9432b
commit
b10b99bd87
120 changed files with 1479 additions and 22 deletions
|
|
@ -1,37 +0,0 @@
|
|||
# filename: ch6-12-global-vars3.rsc
|
||||
|
||||
# In this script, we expect to have several interface names
|
||||
# in a global variable called "WanInterfaces". The variable
|
||||
# should be an array for the script to work correctly
|
||||
|
||||
# Declare the "WanInterfaces" global variable to access
|
||||
# its data (assuming it exists)
|
||||
:global WanInterfaces;
|
||||
|
||||
# Does it have a value? If not, exit with an error
|
||||
if ( [:typeof $WanInterfaces] = "nothing") do={
|
||||
:error "The WanInterfaces global variable is not set. Exiting"
|
||||
}
|
||||
|
||||
# Is the variable an array data type?
|
||||
if ( [:typeof $WanInterfaces] != "array") do={
|
||||
:error "The WanInterfaces global variable is not an array data type. Exiting."
|
||||
}
|
||||
|
||||
# Let's step through the interfaces in the array
|
||||
# and print out their operation status
|
||||
:foreach WanInterface in=$WanInterfaces do={
|
||||
:local InterfaceIndex [/interface ethernet find name=$WanInterface];
|
||||
|
||||
:local UpDown "down";
|
||||
if ([:interface ethernet get $InterfaceIndex]->"running") do={
|
||||
:set UpDown "up"
|
||||
}
|
||||
|
||||
:put "Interface $WanInterface is currently $UpDown";
|
||||
}
|
||||
|
||||
# Let's assume no-one else will need the "WanInterfaces"
|
||||
# variable. Let's remove it from global variables
|
||||
:set WanInterfaces;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue