我正在尝试使用read()和write()命令在服务器上运行一些ping命令。我正在使用连接到Net_ssh2的phpseclib,但当我尝试获取结果并查看echo $ this-> ssh-> getLog()时发生了什么?
这是进入路由器的ssh:
$this->ssh->write('ssh '.$this->userid.'@'.$this->testIPAddress);
$this->ssh->write("\n");
$this->ssh->read('Password:');
$this->ssh->write($this->passwd);
$this->ssh->write("\n");
$this->ssh->read('Welcome');
从那里我得到了我登录到该路由器的成功消息,然后我运行以下ping命令:
$this->ssh->write("ping 172.11.1.221");
$this->ssh->write("\n");
$testLineShowResult = $this->ssh->read('Type');
这是日志返回的内容:
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0005, network: 0.0001s)
00000000 00:00:00:01:00:00:00:01:35 ........5
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0007, network: 0.0001s)
00000000 00:00:00:01:00:00:00:01:34 ........4
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0022, network: 0.0001s)
00000000 00:00:00:01:00:00:00:02:0d:0a ..........
<- NET_SSH2_MSG_CHANNEL_DATA (since last: 0.0018, network: 0.0001s)
00000000 00:00:00:01:00:00:00:9c:52:65:73:6f:75:72:63:65 ........Resource
00000010 20:69:64:20:23:39:52:65:73:6f:75:72:63:65:20:69 id #9Resource i
00000020 64:20:23:39:52:65:73:6f:75:72:63:65:20:69:64:20 d #9Resource id
00000030 23:39:52:65:73:6f:75:72:63:65:20:69:64:20:23:39 #9Resource id #9
00000040 52:65:73:6f:75:72:63:65:20:69:64:20:23:39:70:69 Resource id #9pi
00000050 6e:67:20:31:37:32:2e:31:20:20:20:5e:36:2e:31:2e ng 172.1 ^6.1.
00000060 32:35:34:0d:0a:0d:0a:25:20:49:6e:76:61:6c:69:64 254....% Invalid
00000070 20:69:6e:70:75:74:20:64:65:74:65:63:74:65:64:20 input detected
00000080 61:74:20:27:5e:27:20:6d:61:72:6b:65:72:2e:0d:0a at '^' marker...
00000090 0d:0a:69:62:63:5f:34:35:37:39:33:30:30:39:30:37 ..ibc_4579300907
000000a0 5f:63:65:3e _ce>
正如你所看到的,它打印资源ID#9很多次......有谁知道为什么?谢谢:D
答案 0 :(得分:0)
我谷歌“在'^'标记处检测到无效输入”并发现:
https://learningnetwork.cisco.com/thread/28616
引用它,
On the switch you are connected to, does the prompt look similar to this:
switch>
If so, we need to type in "enable" to go into privileged mode, where the prompt will look like this:
switch#