I have a bash script that calls an expect script like so
$SCRIPTS_DIRECTORY/my_expect_script.sh $my_bash_array
I can pass a variable over, it seems, and use it.
For this example the variable seems to be in [lindex $argv 0].
From bash, it will be a bunch of values, e.g. 1 2 3 4 5.
I am trying to figure out how to use expect to grab this variable, save it to an array then loop through the array to spit out multiple commands one at a time.
So my output should be something like
send command 1 \r
send command 2 \r
etc., until it reaches the end of the array.
I thought in expect I would assign it like
array set myArray [lindex $argv 0]
but it looks like I am wrong.
Would anyone have any good places I can look that might explain going from bash to expect better, or know how to do this? I assume its relatively simple, but expect is very iffy with me in some aspects.
[lindex $argv 0]. Why, then, are you trying to use[lindex $argv 5]instead?$my_bash_arrayonly expands to the first element of an array. Maybe your "array" is really a string?lindexreturns a single element from a list;array setexpects as its last argument an even-numbered list of name-value pairs. In Tcl/expect, an "array" is actually an associative array, and a "list" is a numerically-indexed array.