0 votes
by (520 points)
edited
  Rebex.Net.Ssh ssh = new Ssh();
  ssh.Connect("192.168.1.10");
  ssh.CheckConnectionState();
  ssh.Timeout = 60 * 1000;

  ssh.Login("user", "password");
  string blah = ssh.RunCommand("show config"); // this works fine

  Shell shell = ssh.StartShell(ShellMode.Prompt);
  shell.Prompt = @">";
  shell.Encoding = System.Text.Encoding.UTF8;

  string r = string.Empty;
  shell.SendCommand("set cli screen-length 0"); // times out here.
  string prompt = shell.ReadAll();
  shell.Prompt = prompt.Substring(prompt.LastIndexOf("\n") + 1) + ">";

the above code throws a TerminalException: Response reading timed out. this code works on cisco devices.

help?

by (520 points)
edited

the server Rebex reports is running on the Juniper switch is: "SSH-2.0-OpenSSH_4.4" cisco uses: "SSH-1.99-Cisco-1.25"

2 Answers

+1 vote
by (70.2k points)
edited
 
Best answer

This seems to be a limit of the Shell class. Can you please try to use our experimental VirtualShell class? It is more flexible. You can use it like this:

Rebex.Net.Ssh ssh = new Ssh();
...
VirtualTerminal vt = ssh.StartVirtualTerminal();
VirtualShell shell = new VirtualShell(vt);

shell.Prompt = Regex.Escape(@">");
shell.Terminal.Options.Encoding = System.Text.Encoding.UTF8;

string r = string.Empty;
shell.SendCommand("set cli screen-length 0");
string prompt = shell.ReadAll();
shell.Prompt = Regex.Escape(prompt.Substring(prompt.LastIndexOf("\n") + 1) + ">");
0 votes
by (15.2k points)
edited

Hi, we have just release new Scripting API in 2014-R2 release. You can read more of its features on Scripting features page.

...