c# 用telnet 登陆交换机 查询及返回列表
命令列表:
Password: ****
C1500> enable
Enable Password: ****
C1500# configure terminal
C1500(config)# interface pon 1/1
%Enter configuration commands.End with Ctrl+Z or command "exit" & "end"
C1500(config-if-pon-1/1)#show legal-onu-info
ONU-ID LLID Status MAC address Type Dist(M) ActiveTime
--------------------------------------------------------------------------------
01/01:01 4 online 00:1a:69:7c:27:fd M5-0404E 34 2013/10/24 19:2
2:57
01/01:02 1 online 00:1a:69:7c:27:8d M5-0404E 37 2013/10/24 19:2
2:54
01/01:03 2 online 00:1a:69:78:fc:2b M5-0404E 34 2013/10/24 19:2
3:04
01/01:04 3 online 00:1a:69:7c:28:3f M5-0404E 34 2013/10/24 19:2
3:00
代码:
取到的返回值都是空,有木有人用这种方法真正实现过(我主要是想取到最后的那个列表并在窗体里面显示)
Password: ****
C1500> enable
Enable Password: ****
C1500# configure terminal
C1500(config)# interface pon 1/1
%Enter configuration commands.End with Ctrl+Z or command "exit" & "end"
C1500(config-if-pon-1/1)#show legal-onu-info
ONU-ID LLID Status MAC address Type Dist(M) ActiveTime
--------------------------------------------------------------------------------
01/01:01 4 online 00:1a:69:7c:27:fd M5-0404E 34 2013/10/24 19:2
2:57
01/01:02 1 online 00:1a:69:7c:27:8d M5-0404E 37 2013/10/24 19:2
2:54
01/01:03 2 online 00:1a:69:78:fc:2b M5-0404E 34 2013/10/24 19:2
3:04
01/01:04 3 online 00:1a:69:7c:28:3f M5-0404E 34 2013/10/24 19:2
3:00
代码:
private void button1_Click(object sender, EventArgs e)
{
Process p = null;
p = new Process();
p.StartInfo.FileName = "cmd";
p.StartInfo.Arguments = "/K start telnet 192.168.8.101";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = false;
p.Start();
p.OutputDataReceived+=new DataReceivedEventHandler(p_OutputDataReceived);
SendKeys.Send("123456\r");
System.Threading.Thread.Sleep(500);
SendKeys.Send("enable\r");
System.Threading.Thread.Sleep(500);
SendKeys.Send("123456\r");
System.Threading.Thread.Sleep(500);
SendKeys.Send("configure terminal\r");
System.Threading.Thread.Sleep(500);
SendKeys.Send("interface pon 1/1\r");
System.Threading.Thread.Sleep(500);
SendKeys.Send("show legal-onu-info\r");
System.Threading.Thread.Sleep(800);
p.BeginOutputReadLine();
p.WaitForExit();
p.Close();
}
private void p_OutputDataReceived(object Sender, DataReceivedEventArgs e)
{
if (e.Data != null)
{
result = e.Data;
}
}
取到的返回值都是空,有木有人用这种方法真正实现过(我主要是想取到最后的那个列表并在窗体里面显示)
...全文
相关推荐
C#开发模拟Telnet登陆MA5620设备
C#开发,模拟telnet登陆华为MA5620设备的GUI,实现发送命令,接收并分析回传信息。想开发GUI配置路由器,交换机等程序的朋友们可以以此作为参考。
telnet 自动登陆工具(原创)
最近在做一个项目,需要用到Telnet源代码. 于是查询了相关协议,并参考了一些网络源代码,编写了一个Telnet自动登陆工具。在XP下,测试成功!提供给有需要的同志使用,欢迎下载!若有不完善的地方,欢迎到本站留言。www.celon.net.cn * -------------------------------------------------------------------------- 命令格式: Telnet_celon.exe Host_IP Username Password Host_IP: 远程主机的IP地址,*.*.*.* Username: 用户名,用于自动登陆 Password: 密码,用于自动登陆 === Telnet自动登陆工具, Code by 兰明. www.celon.net.cn === * --------------------------------------------------------------------------
C# TELNET LIB
C# TELNET LIB
C# telnet
C# telnet,
Telnet远程登陆的实现-计算机网络课程设计
模仿应用Telnet协议,把本地用户所使用的计算机变成远程主机系统的一个终端。 三种主要功能: 1)定义一个网络虚拟终端为远的系统提供一个标准接口。客户机程序不必详细了解远的系统,他们只需构造使用标准接口的程序。


