The Scripting
class uses a shell session with a pseudo-terminal, which means that SSH servers could use various ANSI escape sequences that are not perceived by a user when there is a human operating the terminal, but that could really confuse our scripting interpreter.
For example, a terminal could choose to show a "Hello world" text, but do it like this:
- Write "H".
- Move cursor X position 5 characters to the right.
- Write "w".
- Move cursor X position 6 characters to the left.
- Write "e".
- Move cursor X position 5 characters to the right.
- Write "o".
- ...
A human would not notice this, but the scripting API's might parse the response as "Hweolrllod" instead of "Hello world".
This was an extreme example, but we have observed somewhat similar kinds of behavior with Windows SSH servers, in particular related to the way they structured the output of the prompt. So it would not be surprising if Windows OpenSSH exhibited similar unfortunate behavior. It seems that most Rebex Terminal users use it for interfacing to Unix-like systems, which usually behave in a predictable and straightforward way. We will look into this and see whether we can do anything about it.
In the meantime, consider using the older Shell
API that doesn't use shell with a pseudo-terminal:
var ssh = new Ssh();
ssh.Connect(...);
ssh.Login(...);
Shell shell = ssh.StartCommand(@"type c:\folder\myfile.txt");
string response = shell.ReadAll();