Execute a command in shell mode. @param command The command to be executed in shell mode. @return Result of the command execution, as a String. Waiting for command output is bounded by #getCommandTimeout(). @throws IOException if there are issues communicating with the Netconf server.
(String command)
| 602 | * @throws IOException if there are issues communicating with the Netconf server. |
| 603 | */ |
| 604 | public String runShellCommand(String command) throws IOException { |
| 605 | if (!isConnected()) { |
| 606 | return "Could not find open connection."; |
| 607 | } |
| 608 | try (BufferedReader bufferReader = openExecChannelReader(command)) { |
| 609 | StringBuilder reply = new StringBuilder(); |
| 610 | while (true) { |
| 611 | String line = bufferReader.readLine(); |
| 612 | if (line == null || line.equals(NetconfConstants.EMPTY_LINE)) |
| 613 | break; |
| 614 | reply.append(line).append(NetconfConstants.LF); |
| 615 | } |
| 616 | return reply.toString(); |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | /** |
| 621 | * Execute a command in shell mode. |