org.apache.sshd.client.channel.ChannelExec Java Examples
The following examples show how to use
org.apache.sshd.client.channel.ChannelExec.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SshdHolder.java From super-cloudops with Apache License 2.0 | 5 votes |
@Override public <T> T execWaitForComplete(String host, String user, char[] pemPrivateKey, String password, String command, ProcessFunction<ChannelExec, T> processor, long timeoutMs) throws Exception { return doExecCommand(host, user, pemPrivateKey, password, command, channelExec -> { // Wait for completed by condition. channelExec.waitFor(singleton(ClientChannelEvent.CLOSED), timeoutMs); return processor.process(channelExec); }); }
Example #2
Source File: MockClientSession.java From xenon with Apache License 2.0 | 5 votes |
@Override public ChannelExec createExecChannel(String command) throws IOException { if (createChannelThrows) { throw new IOException("Bang!"); } exec = new MockChannelExec(command, null, null); return exec; }
Example #3
Source File: FuseUtils.java From keycloak with Apache License 2.0 | 5 votes |
public static String getCommandOutput(String user, String password, String command) throws IOException { if (!command.endsWith("\n")) command += "\n"; try (ClientSession session = openSshChannel(user, password); ChannelExec channel = session.createExecChannel(command); ByteArrayOutputStream out = new ByteArrayOutputStream()) { channel.setOut(out); channel.setErr(out); channel.open(); channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED, ClientChannelEvent.EOF), 0); return new String(out.toByteArray()); } }
Example #4
Source File: MockClientSession.java From xenon with Apache License 2.0 | 4 votes |
@Override public ChannelExec createExecChannel(String command, PtyChannelConfigurationHolder ptyConfig, Map<String, ?> env) throws IOException { // TODO Auto-generated method stub return null; }