Community discussions

MikroTik App
 
PteraWireless
newbie
Topic Author
Posts: 34
Joined: Tue Apr 07, 2009 6:37 pm

Beginner Help

Thu Aug 20, 2009 2:19 am

I am wanting to use the following script to change simple queue settings.
Where my confusion is even though :put shows the value of counter is 0 the script exits with "no such item"
I used :global to test line by line from the console.
I have tried {} [] () around $counter but still get "no such item"

:local counter 0;
:local numberofqueues [/queue simple print count];
:set numberofqueues {$numberofqueues-2};
:while ($counter < $numberofqueues) do={/queue simple set $counter burst-limit=3M/3M; :set counter ($counter + 1)};
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Beginner Help

Thu Aug 20, 2009 2:41 am

To iterate through items, use 'for'. While you refer to IDs of items via increasing numbers on the command line, in scripts IDs work differently. Additionally, 'print' works differently in scripts.

This script does what you're trying to do:
:foreach queueID in=[/queue simple find] do={
/queue simple set $queueID burst-limit=3M/3M;
}
HTH,
Felix
Last edited by fewi on Thu Aug 20, 2009 3:00 am, edited 1 time in total.
 
PteraWireless
newbie
Topic Author
Posts: 34
Joined: Tue Apr 07, 2009 6:37 pm

Re: Beginner Help

Thu Aug 20, 2009 2:55 am

OK I am starting to understand that with more thought I soould grasp what is happening here...

but I got a syntax error (line 1 column 39)
The terminal show the error on the = sign after do
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Beginner Help

Thu Aug 20, 2009 3:01 am

I'm sorry, my code was wrong. Should have copied and pasted it into a device first...

I've edit the post to the correct syntax.
 
PteraWireless
newbie
Topic Author
Posts: 34
Joined: Tue Apr 07, 2009 6:37 pm

Re: Beginner Help

Thu Aug 20, 2009 3:07 am

The syntax was no : before the for

now I have a new one...
bad argument name in (line 1 column 14)
V
for queueID in=[/queue simple find] do={/queue simple set $queueID burst-limit=3M/3M;}
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Beginner Help

Thu Aug 20, 2009 3:14 am

':foreach', not ':for'.
 
PteraWireless
newbie
Topic Author
Posts: 34
Joined: Tue Apr 07, 2009 6:37 pm

Re: Beginner Help

Thu Aug 20, 2009 6:19 pm

OK but my problem is the last two entries are default queues that I do not want to change.
That was why I was trying to use the count so I could only change the queues up to them.
 
PteraWireless
newbie
Topic Author
Posts: 34
Joined: Tue Apr 07, 2009 6:37 pm

Re: Beginner Help

Thu Aug 20, 2009 8:43 pm

This does the trick...

:while ($counter < $numberofqueues) do={:set in {"*".[:tostr $counter]}; /queue simple set $in burst-limit=3M/3M; :set counter ($counter + 1)};

Thanks
fewi
For the help pointing me in the right direction.