Strange behaviour on shceduler command

Hello everyone.
Just a quick question.
My apologies if i am supposed to know that but anyway :stuck_out_tongue:
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.

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).

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.

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> ]