Moving a Simple Queue to position 0 via a script

Hello,

I am trying to make a script that will move one of our simple queues to the position 0 on the MikroTik. The reason for this is because we need to have some limits put on users p2p traffic that sign in from a hotspot. Since whenever someone logs into the hotspot the dynamic queue is added to the top of the list. As the p2p queue gets pushed down the list it will not apply to the queues above it, and does us no good to have it.

I know the command to get it to move it to position 0 from the command line.

/queue simple move "Limit p2p" destination=0

The problem that I have is when this is put into a script, instead of moving it to position 0 like it should it moves it to position 1 every time. However when I input the command directly to the command line, it moves it to position 0 without any problems.

Does anyone know why this is, is there a way around this or a way to fix it? We are running 4.5 on most of our boxes.

To use queue serial numbers in a script, you should first use the print command. Modify your script as shown below.

/queue simple print  brief without-paging
/queue simple move "Limit p2p" destination=0

Thanks a lot. That appears to have gotten it.

You are welcome. Glad to be of assistance.

why we should print in first?

print is unreliable in scripting because there is no shell. it may break with different versions of RouterOS as well. HEre is what I use for moving mangle rules, the same should work for queues I assume:

/ip firewall mangle move [ /ip firewall mangle find chain=“forward” dynamic=yes] 0

Maybe this?

/queue simple move [/queue simple find name=“Limit p2p”] 0

This code, when used in a script will move “Limit p2p” queue to number 1 not 0

I have have found print to be very reliable in scripting when compelled to print brief without-paging.

Scripting IDs are different from command line IDs. Best way I have found is to do:

/queue simple move [find name="Limit p2p"] [:pick [find] 0]

The “:pick [find] 0” does a find command on all the queue rules and “picks” rule 0, which is the internal RotuerOS ID of the top rule in the queue list.