Used language: TCL / Expect
When I print the output of the expect_out(buffer), it removes the whole printed line for some kind of reason. I have no clue on what is doing this. I've even broken down the "puts" output with -nonewline to be sure and this output also vanished for this line.
Code:
set var $expect_out(0,string)
foreach line [split $var \n] {
puts -nonewline "line: "
puts $line
}
output:
somedata
line: somemoredata
line: evensomemoredata
expected output:
line: somedata
line: somemoredata
line: evensomemoredata
What can cause this output? How can I even troubleshoot this?
*Edit after answer:
To help others with this problem in Expect, it helps to add the following command in your expect script to troubleshoot:
exp_internal 1
This shows everything that is going on, including the values in the buffer that were returned.
Usually in Expect, \n
chars in the spawned program's output will be converted to \r\n
. You can manually remove the \r
chars like this:
set var $expect_out(0,string)
set var [regsub -all "\r" $var ""]
... ...