bash - {expect} - how to create the variable's name within a loop after (flight) take-off? -


this full script:

#!/usr/bin/expect  set a1 "aaa" set a2 "bbb" set a3 "ccc"  {set b 1} {$b<4} {incr b} {    send a$b } 

the output is:

 a1a2a3 

what wanted values for

$a1 $a2 $a3 

how fix ?

someone recommended "eval"

   eval send "a$b" 

which not seem working, outputs same thing above.

it want array:

array set myarr {     a1 "aaa"     a2 "bbb"     a3 "ccc" }  foreach {var value} [array myarr] {    puts "color: $var count: $value"  } 

this code outputs me:

color: a3 count: ccc color: a1 count: aaa color: a2 count: bbb 

so don't have order.

or you're looking list:

set mylist {"aaa" "bbb" "ccc"} lappend mylist "ddd"   foreach elem $mylist {     puts $elem } 

this output exactly:

aaa bbb ccc ddd 

this page should make such things pretty clear you


Comments

Popular posts from this blog

ruby on rails - Is it the correct way to implement belongs_to relation with factory girl? -

geolocation - Windows Phone 8 - Keeping background location tracking active beyond four hours -

Uncaught TypeError: Cannot read property 'parentNode' of null javascript -