| | |
| | | * 执行路由器命令 |
| | | */ |
| | | public String executeCommand(String command,String username,String password,String hostname) { |
| | | if (!isConnected()) { |
| | | if (!connect(username,hostname,password)) { |
| | | return null; |
| | | } |
| | | // if (!isConnected()) { |
| | | // if (!connect(username,hostname,password)) { |
| | | // return null; |
| | | // } |
| | | // } |
| | | if (!connect(username,hostname,password)) { |
| | | return null; |
| | | } |
| | | |
| | | try { |
| | |
| | | |
| | | reader.close(); |
| | | channel.disconnect(); |
| | | disconnect(); |
| | | return output.toString(); |
| | | } catch (Exception e) { |
| | | System.err.println("执行命令失败: " + e.getMessage()); |