Page 1 of 1
Beginner Help
Posted: Thu Aug 20, 2009 2:19 am
by PteraWireless
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)};
Re: Beginner Help
Posted: Thu Aug 20, 2009 2:41 am
by fewi
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
Re: Beginner Help
Posted: Thu Aug 20, 2009 2:55 am
by PteraWireless
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
Re: Beginner Help
Posted: Thu Aug 20, 2009 3:01 am
by fewi
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.
Re: Beginner Help
Posted: Thu Aug 20, 2009 3:07 am
by PteraWireless
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;}
Re: Beginner Help
Posted: Thu Aug 20, 2009 3:14 am
by fewi
':foreach', not ':for'.
Re: Beginner Help
Posted: Thu Aug 20, 2009 6:19 pm
by PteraWireless
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.
Re: Beginner Help
Posted: Thu Aug 20, 2009 8:43 pm
by PteraWireless
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.