public bool ExecutionDeviceConnect() { try { if (telnetShell.Connect()) { telnetShell.WaitStr("login"); telnetShell.WriteLine(myExecutionDeviceInfo.user); telnetShell.WaitStr("password"); telnetShell.ClearShowData(); telnetShell.WriteLine(myExecutionDeviceInfo.password); isConnect = telnetShell.WaitStr("Last login"); } else { isConnect = false; } } catch (Exception ex) { ErrorLog.PutInLog(ex); isConnect = false; } return(isConnect); }
public void Strat() { if (telnet.Connect() == false) { Console.WriteLine("connect fail "); } else { telnet.WaitStr("login"); telnet.WriteLine("telnet"); telnet.WaitStr("password"); telnet.WriteLine("lijie1515"); telnet.WaitStr("$"); Console.WriteLine(telnet.GetAndMoveShowData()); //Console.WriteLine("-------------------------------------------"); //Console.WriteLine(telnet.SessionLog); //Console.WriteLine("-------------------------------------------"); Console.WriteLine(telnet.GetAndMoveShowData()); telnet.WriteLine("ls"); telnet.WaitStr("$"); Console.WriteLine(telnet.GetAndMoveShowData()); Console.WriteLine("-------------------------------------------"); Console.WriteLine(telnet.AllLogData); Console.WriteLine("-------------------------------------------"); Console.ReadLine(); telnet.OnMesageReport += telnet_OnMesageReport; for (int i = 0; i < 10; i++) { telnet.WriteLine("netstat"); } telnet.OnMesageReport -= telnet_OnMesageReport; Console.ReadLine(); Console.WriteLine("******************************************"); Console.WriteLine(telnet.DoRequest("ll", "$ ")); Console.WriteLine("******************************************"); Console.WriteLine(telnet.DoRequest("mkdir 123", "$ ")); Console.WriteLine("******************************************"); Console.WriteLine(telnet.DoRequest("ll", "$ ")); Console.WriteLine("******************************************"); Console.ReadLine(); telnet.DisConnect(); } }