This one is weird. It sends the first command and second command properly and also the 3rd, but the fourth is one behind.
example code:
// update it on the switch.
Rebex.Net.Ssh ssh = new Ssh();
ssh.Connect("...");
ssh.CheckConnectionState();
ssh.Timeout = 10 * 1000;
ssh.Login("...", "...");
string prompt = "";
// we use the virtual classes for comm
VirtualTerminal vt = ssh.StartVirtualTerminal();
VirtualShell shell = new VirtualShell(vt);
shell.Terminal.Options.Encoding = System.Text.Encoding.UTF8;
shell.Prompt = Regex.Escape(@"#");
shell.SendCommand("term len 0");
Console.WriteLine(shell.ReceivedData);
Console.WriteLine(shell.ReadAll());
Console.WriteLine(shell.ReceivedData);
shell.Prompt = Regex.Escape(prompt.Substring(prompt.LastIndexOf("\n") + 1) + "#");
shell.SendCommand("show version");
Console.WriteLine(shell.ReceivedData);
Console.WriteLine(shell.ReadAll());
Console.WriteLine(shell.ReceivedData);
shell.SendCommand("term len 0");
Console.WriteLine(shell.ReceivedData);
Console.WriteLine(shell.ReadAll());
Console.WriteLine(shell.ReceivedData);
shell.SendCommand("show version");
Console.WriteLine(shell.ReceivedData);
Console.WriteLine(shell.ReadAll());
Console.WriteLine(shell.ReceivedData);
Results:
c3560-dc7-hje-mgmt-1
c3560-dc7-hje-mgmt-1#
term len 0
c3560-dc7-hje-mgmt-1
c3560-dc7-hje-mgmt-1#
show version
Cisco IOS Software, C3560E Software (C3560E-UNIVERSALK9-M), Version 15.0(1)SE, R
ELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2011 by Cisco Systems, Inc.
Compiled Wed 20-Jul-11 09:21 by prod_rel_team
...
c3560-dc7-hje-mgmt-1#
term len 0
c3560-dc7-hje-mgmt-1
c3560-dc7-hje-mgmt-1#
The last command should have printed out the version as the previous did... you have to call shell.ReadAll() again... to view the results... so it looks like the commands somehow get behind. this looks like a bug. ideas?