Hi.
Trying to use the rebex telnet library to configure a Linux based router programmatically in c# via the router's telnet interface. My code is based largely on the example documented here:
http://www.rebex.net/support/tutorial/telnet/default.aspx#custom-authentication
Code:
Telnet client = new Telnet("192.168.88.2");
Shell shell = client.StartShell();
shell.Prompt = String.Format("mask:[user@server] *> ");
string prompt = shell.ReadAll("ogin: ");
shell.SendCommand("admin");
prompt = shell.ReadAll("sword: ");
shell.SendCommand("", true);
prompt = shell.ReadAll();
// exception on the next line
shell.SendCommand("interface");
prompt = shell.ReadAll();
shell.Close();
Login is successful, but when I attempt to send my first command it throws an exception:
Rebex.TerminalEmulation.TerminalException was unhandled
HResult=-2146233088
Message=Unable to process command.
Source=Rebex.Terminal
StackTrace:
at Rebex.TerminalEmulation.Shell.SendCommand(String command, Boolean password)
at Rebex.TerminalEmulation.Shell.SendCommand(String command)
at telnetlibtestapp.Form1.button1_Click(Object sender, EventArgs e) in c:\Users\RIME\Documents\Visual Studio 2012\Projects\telnetlibtestapp\telnetlibtestapp\Form1.cs:line 37
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at telnetlibtestapp.Program.Main() in c:\Users\RIME\Documents\Visual Studio 2012\Projects\telnetlibtestapp\telnetlibtestapp\Program.cs:line 19
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
I have tried several different commands, all throw the same exception. The odd thing is that I use shell.SendCommand() during the login process. What am I missing?
Thanks in advance.