Have a expect script:
....
spawn -noecho sshpass -e ssh -e "~" -o "KexAlgorithms diffie-hellman-group1-sha1" -o "HostKeyAlgorithms ssh-dss" -o "Ciphers aes256-cbc" HostIp
expect -timeout 30 "XXXXX> " {
send "YYYYY\r"
} \
timeout {
puts "\n\n!!!Failure: Go to YYYYY Environment!!!\n\r";
interact {
\001 {
send_user "\n\nUser interaction completed.\n\n"
return
}
}
}
puts "\nCorrect Envrionment\n"
...
the scripts outputs:
XXXXX>
Correct Envrionment
YYYYY
when the expected output should be
XXXXX> YYYYY
Correct Envrionment
as state in this post got the ideia why "puts" is faster in its output then "send" even if "send" is invoked first, but how to force the "puts" output to show after the "send" output?
the First answer in that post refers to
flush stdout
but thats tcl don't see that command flush in expect and that would make the "puts" output even faster when the probleam here is it already to fast...
the second answer is good where explains well the behaiver and why that is expected but the solutions don't seem good in the long run is there some kind of flag to indicate that puts should run only after send as been completed?