Package com.sshtools.client.shell
Class ShellController
java.lang.Object
com.sshtools.client.shell.ShellController
- All Implemented Interfaces:
ShellReader,ShellWriter
- Direct Known Subclasses:
ShellProcessController
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected InputStreamprotected ShellMatcherprotected intprotected ExpectShell -
Method Summary
Modifier and TypeMethodDescriptionvoidSend a carriage return to the remote command.booleanConsume the output of the command until the pattern matches.booleanConsume the output of the command until the pattern matches.booleanConsume the output of the command until the pattern matches.booleanConsume the output of the command until the pattern matches.booleanConsume the output of the command until the pattern matches.booleanexpectNextLine(String pattern) Perform expect on the next line of output onlybooleanexpectNextLine(String pattern, boolean consumeRemainingLine) Perform expect on the next line of output onlybooleanexpectNextLine(String pattern, boolean consumeRemainingLine, long timeout) Perform expect on the next line of output onlyintvoidInterrupt the process by sending a Ctrl+C to the process.booleanisActive()booleanisEOF()readLine()Read a line of output from the process.readLine(long timeout) Read a line of output from the process.voidsetMatcher(ShellMatcher matcher) voidsetReadlimit(int readlimit) voidSend data to the remote command just like the user had typed it.voidtypeAndReturn(String string) Send data to the remote command and finish with a carriage return.
-
Field Details
-
shell
-
matcher
-
readlimit
protected int readlimit -
in
-
-
Method Details
-
setMatcher
-
interrupt
Description copied from interface:ShellWriterInterrupt the process by sending a Ctrl+C to the process.- Specified by:
interruptin interfaceShellWriter- Throws:
IOException
-
type
Description copied from interface:ShellWriterSend data to the remote command just like the user had typed it.- Specified by:
typein interfaceShellWriter- Parameters:
string- the typed key data- Throws:
IOException
-
carriageReturn
Description copied from interface:ShellWriterSend a carriage return to the remote command.- Specified by:
carriageReturnin interfaceShellWriter- Throws:
IOException
-
typeAndReturn
Description copied from interface:ShellWriterSend data to the remote command and finish with a carriage return.- Specified by:
typeAndReturnin interfaceShellWriter- Parameters:
string- String- Throws:
IOException
-
expect
Consume the output of the command until the pattern matches. This version of expect will return with the output at the end of the matched pattern.- Parameters:
pattern-- Returns:
- Throws:
ShellTimeoutExceptionSshException
-
expect
public boolean expect(String pattern, boolean consumeRemainingLine) throws ShellTimeoutException, SshException Consume the output of the command until the pattern matches. Use the consumeRemainingLine variable to indicate if output should start at the end of the matched pattern (consumeRemainingLine=false) or at the begninng of the next line (consumeRemainingLine=true)- Parameters:
pattern-consumeRemainingLine-- Returns:
- Throws:
ShellTimeoutExceptionSshException
-
expect
Consume the output of the command until the pattern matches. Use the consumeRemainingLine variable to indicate if output should start at the end of the matched pattern (consumeRemainingLine=false) or at the begninng of the next line (consumeRemainingLine=true)- Parameters:
pattern-timeout-- Returns:
- Throws:
ShellTimeoutExceptionSshException
-
expect
public boolean expect(String pattern, boolean consumeRemainingLine, long timeout) throws ShellTimeoutException, SshException Consume the output of the command until the pattern matches. This version of expect will not consume the whole line and will return with the output at the end of the matched pattern.- Parameters:
pattern-consumeRemainingLine-timeout-maxLines-- Returns:
- Throws:
ShellTimeoutExceptionSshException
-
expectNextLine
Perform expect on the next line of output only- Parameters:
pattern-- Returns:
- Throws:
ShellTimeoutExceptionSshException
-
expectNextLine
public boolean expectNextLine(String pattern, boolean consumeRemainingLine) throws ShellTimeoutException, SshException Perform expect on the next line of output only- Parameters:
pattern-consumeRemainingLine-- Returns:
- Throws:
ShellTimeoutExceptionSshException
-
expectNextLine
public boolean expectNextLine(String pattern, boolean consumeRemainingLine, long timeout) throws ShellTimeoutException, SshException Perform expect on the next line of output only- Parameters:
pattern-consumeRemainingLine-timeout-- Returns:
- Throws:
ShellTimeoutExceptionSshException
-
expect
public boolean expect(String pattern, boolean consumeRemainingLine, long timeout, long maxLines) throws ShellTimeoutException, SshException Consume the output of the command until the pattern matches. This version of expect will not consume the whole line and will return with the output at the end of the matched pattern.- Parameters:
pattern-consumeRemainingLine-timeout-maxLines-- Returns:
- Throws:
ShellTimeoutExceptionSshException
-
isEOF
public boolean isEOF() -
isActive
public boolean isActive() -
readLine
Description copied from interface:ShellReaderRead a line of output from the process.- Specified by:
readLinein interfaceShellReader- Returns:
- Throws:
SshExceptionShellTimeoutException
-
readLine
Description copied from interface:ShellReaderRead a line of output from the process.- Specified by:
readLinein interfaceShellReader- Returns:
- Throws:
SshExceptionShellTimeoutException
-
getReadlimit
public int getReadlimit() -
setReadlimit
public void setReadlimit(int readlimit)
-