Hello, i have a question about the Scripting functionality.
Since bash 5.1, bracketed paste mode is now enabled by default:
2021-07-29 16:20:49.911 VERBOSE Ssh(1)[14] SSH: Received packet SSH_MSG_CHANNEL_DATA (17 bytes).
0000 |5E-00-00-00-00-00-00-00 08-1B-5B-3F-32-30-30-34| ^.........[?2004
0010 |68 | h
2021-07-29 16:20:49.911 VERBOSE Ssh(1)[14] SSH: Received packet SSH_MSG_CHANNEL_DATA (73 bytes).
0000 |5E-00-00-00-00-00-00-00 40-1B-5D-30-3B-61-6E-64| ^.......@.]0;and
0010 |72-65-79-40-75-62-75-6E 74-75-2D-73-65-72-76-65| rey@ubuntu-serve
0020 |72-2D-32-31-2D-30-34-3A 20-7E-07-61-6E-64-72-65| r-21-04: ~.andre
0030 |79-40-75-62-75-6E-74-75 2D-73-65-72-76-65-72-2D| y@ubuntu-server-
0040 |32-31-2D-30-34-3A-7E-24 20 | 21-04:~$
2021-07-29 16:20:49.915 DEBUG Ssh(1)[12] Info: Received 72 bytes of data.
2021-07-29 16:20:49.915 VERBOSE Ssh(1)[12] Info: Received data:
0000 |1B-5B-3F-32-30-30-34-68 1B-5D-30-3B-61-6E-64-72| .[?2004h.]0;andr
0010 |65-79-40-75-62-75-6E-74 75-2D-73-65-72-76-65-72| ey@ubuntu-server
0020 |2D-32-31-2D-30-34-3A-20 7E-07-61-6E-64-72-65-79| -21-04: ~.andrey
0030 |40-75-62-75-6E-74-75-2D 73-65-72-76-65-72-2D-32| @ubuntu-server-2
0040 |31-2D-30-34-3A-7E-24-20 | 1-04:~$
For example, Ubuntu 21.04 contains pre-installed version of bash 5.1:
andrey@ubuntu-server-21-04:~$ dpkg -l | grep bash
ii bash 5.1-2ubuntu1 amd64 GNU Bourne Again SHell
ii bash-completion 1:2.11-2ubuntu1 all programmable completion for the bash shell
ii command-not-found 20.10.1 all Suggest installation of packages in interactive bash sessions
andrey@ubuntu-server-21-04:~$ bind -v | grep bracketed
set enable-bracketed-paste on
andrey@ubuntu-server-21-04:~$
When i use this code, i get a not entirely clean result.
using (var ssh = new Ssh())
{
ssh.Connect(host);
ssh.Login(user, password);
var shell = ssh.StartScripting();
shell.WaitFor(ScriptEvent.Duration(2000));//wait welcome text and first prompt string
shell.Send(FunctionKey.Enter);
shell.WaitFor(ScriptEvent.Duration(2000));//wait second prompt string
var output = shell.ReceivedData;
ssh.Disconnect();
}
My output:
\r\n\randrey@ubuntu-server-21-04:~$
I have an one additional unwanted CR symbol before the prompt string instead bracketed-paste control symbols or something else. I get the same result if i try to send a simple shell command:
shell.SendCommand("date");
shell.WaitFor(ScriptEvent.Duration(2000));//wait second prompt string
var output = shell.ReceivedData;
Output:
\rFri Jul 30 09:10:19 UTC 2021\r\nandrey@ubuntu-server-21-04:~$
Does the Scripting feature have internal functionality to get a cleaner reliable result or additional output control options for a given case?
How safe would it be to manually try to clear the output data from additional CR characters?
Thank you.