admsho
February 16, 2018, 9:37am
1
what is wrong with my code , the code inside do is not working
:foreach user in=[/ip hotspot active find user=“srm”] do={
:local ip [/ip hotspot active get $user address];
:local mac [/ip hotspot active get $user mac-address];
:local username [/ip hotspot active get $user user];
:if($ip=“11.0.0.250”) do={:log info message=“$ip”}
}
Are you sure that type of $ip is string?
admsho
February 16, 2018, 10:02am
3
I’ve tried to run this simple code with script , but no luck
:if(1=1) do={:log info message=“dddddddddd”}
mrz
February 16, 2018, 10:11am
4
Paste that line in terminal and you will see where syntax error is.
[admin@RB2011ILRM] > :if (1=1) do={:log info "dddddddddd"}
[admin@RB2011ILRM] > :if (1=1) do={:log info message="aaaa"}
Both works.
I’ve tried to run this simple code with script , but no luck
:if(1=1) do={:log info message=“dddddddddd”}
You’re missing a space after the “if”. It’s “:if (”, not “:if(”.
admsho
February 16, 2018, 10:28am
7
it works on the terminal, but for some reason is not working in the hotspot user profile script neither the system script
admsho
February 16, 2018, 10:30am
8
yes, it was the space issue , thanks alot, isn’t there a compiler that can be used to generate the code ,something like visual studio
The easiest way to check code in scripts is to perform
/system script print
All bugs will be shown when scripts are printed to the terminal