Community discussions

MikroTik App
 
surfnetc
just joined
Topic Author
Posts: 4
Joined: Thu Sep 13, 2007 3:31 am

update hotspot users

Fri Jan 14, 2011 1:07 am

I am trying to write a script to update my users profile in hotspot/users
{:if ([/ip hotspot user find name="00:0C:42:69:40:2A" ]  = True)

do={:put [set [/ip hotspot user find name="00:0C:42:69:40:2A"]   profile="Premium" comment="Monteith,Stan"]} 

else={:put [/ip hotspot user add name="00:0C:42:69:40:2A"  profile="Premium"]}}
the problem I have with this script is that is always returns false and does the 'else' command
[admin@Boathouse_Longshot] /ip hotspot user> {:if ([/ip hotspot user find name="00:0C:42:69:40:2A" ]  = True) do={:put [set [/ip hotspot user find 
name="00:0C:42:69:40:2A"]   profile="Premium" comment="Monteith,Stan"]} else={:put [/ip hotspot user add name="00:0C:42:69:40:2A"  profile="Premium"
]}}
failure: already have user with this name for this server
If I use this command.
/ip hotspot user print where name="00:0C:42:69:40:2A"
I get the user printed.. so I know the user exists.. so when do my script always come back false?

to make it a bit more complicated I am also trying to find by the comment.
currently the script run from the command line this does not work
/ip hotspot user print where name="00:0C:42:69:40:2A" AND comment="Monteith,Stan"
[admin@Boathouse_Longshot] /ip hotspot user> /ip hotspot user print where name="00:0C:42:69:40:2A" AND comment="Monteith,Stan"
Flags: X - disabled, D - dynamic 
 #   SERVER                                 NAME                                ADDRESS         PROFILE                                UPTIME 
yet, both
/ip hotspot user print where name="00:0C:42:69:40:2A"
[admin@Boathouse_Longshot] /ip hotspot user> /ip hotspot user print where  name="00:0C:42:69:40:2A"          
Flags: X - disabled, D - dynamic 
 #   SERVER                                 NAME                                ADDRESS         PROFILE                                UPTIME      
 0   ;;; Monteith,Stan
                                            00:0C:42:69:40:2A                                   Premium                                0s 
and
/ip hotspot user print where comment="Monteith,Stan"
[admin@Boathouse_Longshot] /ip hotspot user> /ip hotspot user print where comment="Monteith,Stan"                             
Flags: X - disabled, D - dynamic 
 #   SERVER                                 NAME                                ADDRESS         PROFILE                                UPTIME      
 0   ;;; Monteith,Stan
                                            00:0C:42:69:40:2A                                   Premium                                0s   
work and come back with the same user, so why doesnt it work when I search for both?

thanks!
~Ken
 
User avatar
mbeckwell
just joined
Posts: 4
Joined: Sat Jan 15, 2011 10:04 am
Location: Minneapolis, Minnesota, US

Re: update hotspot users

Sat Jan 15, 2011 5:54 pm

try a lowercase "and"...(at least that's what did it for me)

[matthew@MPLSMNLY] /ip hotspot user> print where name="user1" AND comment="test1"   
Flags: X - disabled, D - dynamic 
 #   SERVER                                        NAME                                       ADDRESS         PROFILE                                       UPTIME 
[matthew@MPLSMNLY] /ip hotspot user> print where name="user1" and comment="test1"
Flags: X - disabled, D - dynamic 
 #   SERVER                                        NAME                                       ADDRESS         PROFILE                                       UPTIME      
 0   ;;; test1
                                                   user1                                                      default                                       0s