命令列表: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;
}
}
取到的返回值都是空,有木有人用这种方法真正实现过(我主要是想取到最后的那个列表并在窗体里面显示)
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;
}
}
取到的返回值都是空,有木有人用这种方法真正实现过(我主要是想取到最后的那个列表并在窗体里面显示)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货