LOOP

Execute a series of commands in a loop

LOOP

Run command lines a fixed number of times, or forever.

loop <count>|* "<command>" …

<count> must be a non-negative number (Invalid loop count otherwise); * means forever. Each further argument is one complete command line, and at least one is required. The loop stops at the first failing command while the LoopError option is on (the default, see set).

Warning

A running loop cannot be interrupted at the drivshell> prompt. loop * ends only when a command fails (with LoopError on) or when syncd restarts. Use a count.

Hardware-validated

drivshell> loop 10 "echo hello world"
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world
hello world

Hardware-validated

drivshell> loop 3 "ps ce0" "sleep quiet 1"
                 ena/        speed/ link auto    STP                  lrn  inter   max   cut   loop
           port  link  Lns   duplex scan neg?   state   pause  discrd ops   face frame  thru?  back   encap
       ce0(  1)  !ena   4  100G  FD   SW  No   Forward         Untag    F    CR4  9122    No          IEEE
                 ena/        speed/ link auto    STP                  lrn  inter   max   cut   loop
           port  link  Lns   duplex scan neg?   state   pause  discrd ops   face frame  thru?  back   encap
       ce0(  1)  !ena   4  100G  FD   SW  No   Forward         Untag    F    CR4  9122    No          IEEE
                 ena/        speed/ link auto    STP                  lrn  inter   max   cut   loop
           port  link  Lns   duplex scan neg?   state   pause  discrd ops   face frame  thru?  back   encap
       ce0(  1)  !ena   4  100G  FD   SW  No   Forward         Untag    F    CR4  9122    No          IEEE

Built-in help

Parameters: <loop-count> "command" ...
    Loop over a series of commands <loop-count> times, if <loop-count>
    is * then is loops forever. Each argument is a complete command,
    so if it contains more that one word it must be placed in quotes.
    For example:

        loop 10 "echo hello world"

    will execute the following command 10 times:

        "echo hello world"

    If the series of commands fails, the loop will stop only if the
    "LoopError" option is true (see the "set" command).

Further reading

SDK-6.5.20 HSDK Getting Started Guide (GS-SDK6520-R), plus SDK-6.5.20/21/22 Release Notes (RN-SDK65xx-R), BCM_SDK命令.