I am writing an Expect script and I have problems with the shell (on Linux). My pending script spawns rloginand the remote system uses ksh. The remote system prompt contains the current directory, followed by " > "(a space greater than a space). A script fragment may be:
send "some command here\r"
expect " > "
This works for simple commands, but things start to go wrong when the command being sent exceeds the width of the terminal (more precisely, which it kshconsiders the width of the terminal). In this case, it kshdoes some weird horizontal scrolling of the interactive command line, which seems to rewrite the prompt and insert an additional ">" in the output. Naturally, this makes the Expect script get confused and not synchronized when more than one prompt appears on the output after executing the command (my script contains several send/ pairs expect).
I tried to change it PS1to something more specific on the remote system, like "prompt>", but there is a similar problem that tells me that this is the wrong way to solve this problem.
What I think might help is the opportunity for the script to say "Expect" that "I know that I am correctly synchronized with the remote system at the moment, so reset the input buffer now." The statement expecthas a flag -notransferthat does not discard the input buffer, even if the pattern matches, so I think I need the opposite of this.
Are there any other useful methods that I can use to make the remote shell more predictable? I understand that Expect does a lot of work to make sure that the session created for spawning is interactive for the remote system, but I would prefer to turn off some of the most annoying interactive functions (like horizontal scrolling ksh).