Community discussions

MikroTik App
 
thecableguy
Trainer
Trainer
Topic Author
Posts: 14
Joined: Sun Oct 06, 2013 3:35 pm

Strange behaviour on shceduler command

Mon Aug 20, 2018 11:31 am

Hello everyone.
Just a quick question.
My apologies if i am supposed to know that but anyway :P
I created a scheduler task with purpose to delete the one and only hotspot user and the re-create it.
So i noticed something strange that was breaking up the task.

In the scheduler I used the command: "/ip hotspot user remove 1"
and to my surprise i got "no such item (4)" ...but the user was there
So i added "ip hotspot user print" and right after, the "/ip hotspot user remove 1" ... and it worked.

My question is this. Isn't the RouterOS aware of users ? Removing directly the user has no effect... but when i use the print command .. it works like a charm.
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11597
Joined: Thu Mar 03, 2016 10:23 pm

Re: Strange behaviour on shceduler command

Mon Aug 20, 2018 11:37 am

Whenever item is referred by number ... that number is dynamic and if you don't get it somehow (e.g. by executing print command) you can not use it.

I guess a two-liner that would work would be something like
/ip hotspot user
remove [ find name=<username> ]
For "find" use whatever criteria is the best (I don't run hotspot so I don't know what kind of metadata is there for user).
 
thecableguy
Trainer
Trainer
Topic Author
Posts: 14
Joined: Sun Oct 06, 2013 3:35 pm

Re: Strange behaviour on shceduler command

Mon Aug 20, 2018 11:50 am

Yes just tried that .. just right after i posted.. and indeed is the best way to do it.
I didnt reallize that the number sequence is created only when the user uses the print command.
I thought it was already there and the OS was aware of this.
My bad.
 
nescafe2002
Forum Veteran
Forum Veteran
Posts: 897
Joined: Tue Aug 11, 2015 12:46 pm
Location: Netherlands

Re: Strange behaviour on shceduler command

Mon Aug 20, 2018 12:17 pm

Note that a "two liner" is not necessary; expression in square brackets is implicitly evaluated in chosen context.
/ip hotspot user remove [ find name=<username> ]

Who is online

Users browsing this forum: Ahrefs [Bot], anav, GoogleOther [Bot] and 118 guests