I need a script for automaticaly check and uncheck tha Radius MAC Authentication box by time limit. For example to uncheck in 9 AM and check in 4 PM.
just parse /system clock time and run appropriate command to change radius mac auth setting.
Sorry I don’t know what you mean? ![]()
# Get numeric time
# Ex. if clock time is 12:31, time = 1231
# Ex. if clock time is 09:23, time = 923
:local time ""
:set time [/system clock get time]
:set time ([:pick $time 0 2] . [:pick $time 3 5])
# remove leading zeros from time
:local loop 1
:local index 0
:while ($loop = 1 && $index < [:len $time]) do={
:if ([:pick $time $index ($index + 1)] != "0") do={
:set time [:pick $time $index [:len $time]]
:set loop 0
}
:set index ($index + 1)
}
# between 9 AM and 4 PM
:if ($time > 900 && $time < 1600) do={
:put "It's between 9 AM and 4 PM"
/interface wireless security-profiles set 0 radius-mac-authentication=no
}
# after 4 PM or before 9 AM
:if ($time > 1600 || $time < 900) do={
:put "It's between 4 PM and 9 AM"
/interface wireless security-profiles set 0 radius-mac-authentication=yes
}
:put $time
Maybe I’m missing something here, but wouldn’t it be easiest to do this via the scheduler?
First, create one script to disable the property, and then another one to enable it:
/system script add name="DisableRADIUSMAC" source="/interface wireless security-profiles set 0 radius-mac-authentication=no"
/system script add name="EnableRADIUSMAC" source="/interface wireless security-profiles set 0 radius-mac-authentication=yes"
And then add two scheduled jobs running at 9am and 4pm, firing the scripts:
/system scheduler add start-date=aug/14/2009 start-time=09:00:00 interval=1d on-event=DisableRADIUSMAC
/system scheduler add start-date=aug/14/2009 start-time=16:00:00 interval=1d on-event=EnableRADIUSMAC
Hope that helps,
Felix
fewi,
that sounds like a better idea since we’re dealing with a time related task
Tnx this help me a lot. And it works well ![]()