#here we exclude default-trial user or else the script won’t excecute the last line
: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]]}
}
Cleaned up the script. Code tags, tabs, if section and removed not needed ;
: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]]
}
}
Shorten some and set the comment, not just show it:
/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]]
}
}
if On login works as i think it does, you´ll just need to change this:
/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]]
before write this post I wanted to have script save comment contain MAC and date and time user login Can this script be developed to contain MAC and time (year, month, day, hour and minute) after user logged?
do not personalize month names, must be on english,
if the output of the last is not
2022-mar-18 16:54
but something like
2022-Mar-18 16:54
or
2022-MAR-18 16:54
the array of month names must be changed accordingly.