this script not work
in /ip hotspot user
i wold to change password when user have profile name “mm”
{
:foreach i in [ /ip hotspot user find where disabled=no ]do={
:if ([ :find [ /ip hotspot user get $i profile] ] = "mm" )do={
[/ip hotspot user set $i password]="aaa"
}
}
}
where is the wrong ??
check this
/ip hotspot user
:foreach i in=[find disabled=no] do={
:local name [ get value-name=name $i]
:local profile [get value-name=profile $i]
:if ( $profile = "mm") do={set password=aaa $name}
}}
The syntax error is you need spaces before the “do”. Also,
[/ip hotspot user set $i password]="aaa"
Doesn’t make sense. Setting the password is part of the command, and the command itself is the outermost, so it doesn’t need the “”, i.e.
/ip hotspot user set $i password="aaa"
What you want to do can be done in a much more simple and efficient fashion though:
/ip hotspot user set [find disabled=no && profile="mm"] password="aaa"
true code is :
{
:foreach i in [ /ip hotspot user find where disabled=no ] do={
:if ([ /ip hotspot user get $i profile] = "mm" ) do={
/ip hotspot user set $i password="aaa"
}
}
}
thank’s for all