My TCL Script is as follows,
set a 1
while {$a < 6} {
set interface [list ge1 vlan$a ge2 vlan$a ge3 vlan$a]
foreach each $interface {
puts $each
}
incr a
}
Now I am getting output as shown below :
C:\Desktop>tclsh loop_through_same_list_increment_variable.tcl
ge1
vlan1
ge2
vlan1
ge3
vlan1
ge1
vlan2
ge2
vlan2
ge3
vlan2
ge1
vlan3
ge2
vlan3
ge3
vlan3
ge1
vlan4
ge2
vlan4
ge3
vlan4
ge1
vlan5
ge2
vlan5
ge3
vlan5
C:\Desktop>
But I am trying to get output as shown below:
ge1
vlan1
vlan2
vlan3
vlan4
vlan5
ge2
vlan1
vlan2
vlan3
vlan4
vlan5
ge3
vlan1
vlan2
vlan3
vlan4
vlan5
I want to loop only vlan's using the above TCL script.
incr ais basically used to increment the numerical values in tcl. It does not matter whether it is inside a loop or not. Your might have to change the logic in the loop.