I'm using a tcl script to open an ssh connection to a linux machine and open a virtual switch application. Inside the switch CLI I add >1000 IP routes.

I run the script as = `./script_name.tcl` and not via `tclsh` because that tends to give me some errors.

The problem is somewhere in how tcl interprets while loop inside tcl script.
My while loops - 

```
sleep 1

set i 1
while {$i < 3 } {
    set j 2
    expect "*#"
    while {$j < 255} {
        send "ip route 2.2.$i.$j 255.255.255.255 4.4.4.1\r"
        incr j
    }
    incr i
}

sleep 1
expect "*#"

set k 1
while {$k < 3 } {
    set l 2
    expect "*#"
    while {$l < 255} {
        send "ip route 1.1.$k.$l 255.255.255.255 1.1.1.5\r"
        incr l
    }
    incr k
}

```

I use 2 while loops for adding ~500 routes each, so the total should make >1000 routes. The problem is only first ~500 routes are added and the next while loop doesn't works. The next while loop displays to be working in CLI, but the routes are actually not added.

But if I use 1 while loop to add 1000 routes. I change the while loop counter from `{$i < 3 }` to `{$i < 5 }` and it works.

Somehow the second loop is not getting executed properly.