Please use ***
[code][/code]*** tags around your code and data, to preserve the original formatting and to improve readability. Do
not use quote tags, bolding, colors, "start/end" lines, or other creative techniques.
I'm not at all familiar with
expect, but one of the most common mistakes in the shell is attempting to store quotes or other shell syntax in variables.
I'm trying to put a command in a variable, but the complex cases always fail!
http://mywiki.wooledge.org/BashFAQ/050
It may or may not be related to your problem, but if it's possible, try removing the quotes from the variable and instead include them in the
expect script itself (assuming I'm reading the code correctly).
In addition, I believe the key line in your error message is this:
Code:
extra characters after close-quote
So your ultimate goal should be to locate these "extra characters", figuring out why they are appearing, and eliminate them. I'm guessing that the embedded quotes are forcing the parsing to somehow end prematurely, or similar.
Finally, I also
highly suggest moving all that code into a
function, and running that, instead of trying to shove it all into the
$(..) bracket.