how can save mac address in a comment after login , hotspot user
thanks
:foreach i in=[/ip hotspot user find where name!=default-trial] do={
:local uptime [/ip hotspot user get number=$i uptime]
#if an user have 00:00:00 uptime means it's not connected right? then...
:if ($uptime=00:00:00) do={
:log info "User$i Not Connected"
} else={
#i don't know where do you want to add the comments so i did it right there in /ip hotspot user just as an example
:put [/ip hotspot user set number=$i comment=[/ip hotspot user get number=$i mac-address]]
}
}
/ip hotspot user
:foreach i in=[find where name!=default-trial] do={
:local uptime [user get number=$i uptime]
#if an user have 00:00:00 uptime means it's not connected right? then...
:if ($uptime=00:00:00) do={
:log info "User$i Not Connected"
} else={
set number=$i comment=[get number=$i mac-address]]
}
}
:local a $user
:local m [/ip hotspot active get [find user=$a] mac-address]
:log info message=("Prueba: ;$a; ;$m;");
/ip hotspot user set $a mac=$m;
if On login works as i think it does, you´ll just need to change this:thank you I'll try to this script
but I have another script use it in a (On login) tab in this path (( ip > hotspot > User Profiles > Scripts > On login ))
but this script add MAC in MAC address field not in a comment, Can we make some changes rules in this script so that put MAC in a comment?Code: Select all:local a $user :local m [/ip hotspot active get [find user=$a] mac-address] :log info message=("Prueba: ;$a; ;$m;"); /ip hotspot user set $a mac=$m;
thanks so much
thaaaaaaaaaanks so much @JaviGL93if On login works as i think it does, you´ll just need to change this:thank you I'll try to this script
but I have another script use it in a (On login) tab in this path (( ip > hotspot > User Profiles > Scripts > On login ))
Code: Select all:local a $user :local m [/ip hotspot active get [find user=$a] mac-address] :log info message=("Prueba: ;$a; ;$m;"); /ip hotspot user set $a mac=$m;
but this script add MAC in MAC address field not in a comment, Can we make some changes rules in this script so that put MAC in a comment?
thanks so much
/ip hotspot user set $a mac=$m;
for this:
/ip hotspot user set $a comment=$m; (cause you mean a comment right there in /ip hotspot user right?)
let us know.
Thanks @Jotne but the shortened version of my script didn't worked out for me, even when i added : and [ to --> set number=$i comment=[get number=$i mac-address]]
You could save previous comment and then :set $mac and $previous_comment together
another question please
the script added MAC in a comment but deleted old comment, Is it possible to add comment not replace comment?
:local previous_comment [/ip hotspot user get $a comment]
/ip hotspot user set $a comment="$previous_comment --> $m"
*btw if an user mac address change the comment will show old and new mac address too
:local mac $"mac-address"
:log info "Prueba: $user $mac"
/ip hotspot user
:local comentario [get $user comment]
set $user comment="$mac - $comentario"
:local arrMonths {jan="01";feb="02";mar="03";apr="04";may="05";jun="06";jul="07";aug="08";sep="09";oct="10";nov="11";dec="12"}
:local curdatetime "$[/system clock get date] $[/system clock get time]"
:local ldate ("$[:pick $curdatetime 7 11]-$($arrMonths->[:pick $curdatetime 0 3])-$[:pick $curdatetime 4 6] $[:pick $curdatetime 12 14]:$[:pick $curdatetime 15 17]")
:local mac $"mac-address"
:log info "Prueba: $user $mac"
/ip hotspot user
:local comentario [get $user comment]
set $user comment="$mac $ldate - $comentario"
{
:local arrMonths {jan="01";feb="02";mar="03";apr="04";may="05";jun="06";jul="07";aug="08";sep="09";oct="10";nov="11";dec="12"}
:local curdatetime "$[/system clock get date] $[/system clock get time]"
:local ldate ("$[:pick $curdatetime 7 11]-$($arrMonths->[:pick $curdatetime 0 3])-$[:pick $curdatetime 4 6] $[:pick $curdatetime 12 14]:$[:pick $curdatetime 15 17]")
:put $ldate
}
{
:local curdatetime "$[/system clock get date] $[/system clock get time]"
:local ldate ("$[:pick $curdatetime 7 11]-$[:pick $curdatetime 0 3]-$[:pick $curdatetime 4 6] $[:pick $curdatetime 12 14]:$[:pick $curdatetime 15 17]")
:put $ldate
}
:local arrMonths {jan="01";feb="02";mar="03";apr="04";may="05";jun="06";jul="07";aug="08";sep="09";oct="10";nov="11";dec="12"}
:local curdatetime "$[/system clock get date] $[/system clock get time]"
:local ldate ("$[:pick $curdatetime 7 11]-$($arrMonths->[:pick $curdatetime 0 3])-$[:pick $curdatetime 4 6] $[:pick $curdatetime 12 14]:$[:pick $curdatetime 15 17]")
:local mac $"mac-address"
:log info "Prueba: $user $mac"
/ip hotspot user
:local comentario [get $user comment]
set $user comment="$mac $ldate - $comentario"