- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Java ganymed 库通过 SSH2 连接到我们的交换机。我可以毫无问题地连接 Catalyst 交换机,但是当我连接到 Nexus 交换机时,我无法从命令中获得任何输出。
有人用过这个库来连接 Nexus 交换机吗?
具体代码部分如下:
try {
Connection conn = new Connection(IP);
conn.connect();
boolean isAuthenticated = conn.authenticateWithPassword(username, password);
if (isAuthenticated) {
Session sess = conn.openSession();
sess.startShell();
InputStream stdout = new StreamGobbler(sess.getStdout());
BufferedReader br = new BufferedReader(new InputStreamReader(stdout));
OutputStream stdin = new BufferedOutputStream(sess.getStdin());
BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(stdin));
bw.write("sh cdp ne");
bw.flush();
stdin.write(13);
stdin.flush();
bw.write("exit");
bw.flush();
stdin.write(13);
stdin.flush();
while (true)
{
String line = br.readLine();
System.out.println(line);
if (line == null)
break;
}
} // close if (isAuthenticated)
} // close try
最佳答案
显然问题是“没有分配伪终端,而你的命令 cdp 需要一个。”正如@SubOptimal 警告的那样。所以我为 session 分配了一个伪终端,问题就解决了:
Session sess = conn.openSession();
sess.requestDumbPTY(); // Allocate a pseudo-terminal for this session.
sess.startShell(); // Start a shell on the remote machine.
感谢大家的评论。
关于java - SSH 到 Cisco Nexus 交换机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35620604/
如何收集设备/交换机上的带宽使用情况/利用率。据我所知,有些系统可以做这样的事情。他们似乎都有 snmp 的共同点。 我正在寻找有关可能滚动我自己的系统来收集这些数据的信息,这些数据稍后将用于基于 W
下表给出的 DES-3528 DLink 交换机的 OID 是什么 DES-3528:admin#show snmp comm 命令:显示 snmp 社区 SNMP 社区表 社区名称查看名称访问权限
我正在使用 Java ganymed 库通过 SSH2 连接到我们的交换机。我可以毫无问题地连接 Catalyst 交换机,但是当我连接到 Nexus 交换机时,我无法从命令中获得任何输出。 有人用过
我需要使用 php 远程登录到 cisco 交换机并执行 show interface status命令并获得结果。我尝试了一些在互联网上找到的 php 类,但它们都无法连接到设备。所以我尝试自己编写
这个问题已经有答案了: React Router v4 renders multiple routes (3 个回答) 已关闭 5 年前。 我见过各种例子,说当使用React Router V4时,你
我目前正在尝试编写一个脚本来更改 200 多台 Cisco 交换机的位置 (snmp)。 我的问题是我一次不能运行多个命令。我制作了一个批处理文件,它自动连接到交换机并读取列出命令的 .txt 文件。
我正在使用此代码 https://gist.github.com/svett/b7f56afc966a6b6ac2fc作为起点。 使用它并将其指向 cisco 路由器会得到以下错误消息: 拨号失败:s
我最近进入了 PhantomJS 目前正在使用 PhantomJS 来完成我的第一份开发工作。 我的任务是从通过 LAN 电缆连接到 PC 的旧 Cisco Catalyst 2960 x 交换机上抓
日前,IDC 发布的《2020 年网络市场跟踪报告》显示,2020 年全球网络市场规模为 490.1 亿美元,与去年同期相比下滑 3%,其中交换机、路由器和 WLAN 市场增速分别为 - 3.5%、
我是一名优秀的程序员,十分优秀!