Package me.saro.commons.ssh
Class SSHShell
- java.lang.Object
-
- me.saro.commons.ssh.SSHShell
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class SSHShell extends java.lang.Object implements java.io.CloseableSSH Shell- Since:
- 1.2
-
-
Method Summary
Modifier and Type Method Description voidclose()close
include cmdExitAndJoinEOF();voidcmd(java.lang.String... cmds)send commendvoidcmdExitAndJoinEOF()send commend "exit" and wait EOF
this method will ignore exceptions
there is the same next 2 line
cmd("exit");
joinEOF();booleanisConnected()connectedvoidjoinEOF()cmd("exit"); and wait outputstatic SSHShellopen(java.lang.String host, int port, java.lang.String user, java.lang.String pass, java.lang.String charset, ThrowableConsumer<java.lang.String> readLines)open ssh
-
-
-
Method Detail
-
open
public static SSHShell open(java.lang.String host, int port, java.lang.String user, java.lang.String pass, java.lang.String charset, ThrowableConsumer<java.lang.String> readLines) throws java.io.IOException
open ssh- Parameters:
host-port-user-pass-charset-- Returns:
- Throws:
java.io.IOException
-
cmd
public void cmd(java.lang.String... cmds) throws java.io.IOExceptionsend commend- Parameters:
cmd-- Throws:
java.io.IOException
-
cmdExitAndJoinEOF
public void cmdExitAndJoinEOF() throws java.io.IOException, java.lang.InterruptedExceptionsend commend "exit" and wait EOF
this method will ignore exceptions
there is the same next 2 line
cmd("exit");
joinEOF();- Throws:
java.io.IOExceptionjava.lang.InterruptedException
-
joinEOF
public void joinEOF() throws java.lang.InterruptedExceptioncmd("exit"); and wait output- Throws:
java.lang.InterruptedException
-
isConnected
public boolean isConnected()
connected- Returns:
-
close
public void close() throws java.io.IOExceptionclose
include cmdExitAndJoinEOF();- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
-