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 InputStream
protected ShellMatcher
protected int
protected ExpectShell
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Send a carriage return to the remote command.boolean
Consume the output of the command until the pattern matches.boolean
Consume the output of the command until the pattern matches.boolean
Consume the output of the command until the pattern matches.boolean
Consume the output of the command until the pattern matches.boolean
Consume the output of the command until the pattern matches.boolean
expectNextLine
(String pattern) Perform expect on the next line of output onlyboolean
expectNextLine
(String pattern, boolean consumeRemainingLine) Perform expect on the next line of output onlyboolean
expectNextLine
(String pattern, boolean consumeRemainingLine, long timeout) Perform expect on the next line of output onlyint
void
Interrupt the process by sending a Ctrl+C to the process.boolean
isActive()
boolean
isEOF()
readLine()
Read a line of output from the process.readLine
(long timeout) Read a line of output from the process.void
setMatcher
(ShellMatcher matcher) void
setReadlimit
(int readlimit) void
Send data to the remote command just like the user had typed it.void
typeAndReturn
(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:ShellWriter
Interrupt the process by sending a Ctrl+C to the process.- Specified by:
interrupt
in interfaceShellWriter
- Throws:
IOException
-
type
Description copied from interface:ShellWriter
Send data to the remote command just like the user had typed it.- Specified by:
type
in interfaceShellWriter
- Parameters:
string
- the typed key data- Throws:
IOException
-
carriageReturn
Description copied from interface:ShellWriter
Send a carriage return to the remote command.- Specified by:
carriageReturn
in interfaceShellWriter
- Throws:
IOException
-
typeAndReturn
Description copied from interface:ShellWriter
Send data to the remote command and finish with a carriage return.- Specified by:
typeAndReturn
in interfaceShellWriter
- Parameters:
string
- String- Throws:
IOException
-
expect
public boolean expect(String pattern) throws ShellTimeoutException, com.sshtools.common.ssh.SshException 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:
ShellTimeoutException
com.sshtools.common.ssh.SshException
-
expect
public boolean expect(String pattern, boolean consumeRemainingLine) throws ShellTimeoutException, com.sshtools.common.ssh.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:
ShellTimeoutException
com.sshtools.common.ssh.SshException
-
expect
public boolean expect(String pattern, long timeout) throws ShellTimeoutException, com.sshtools.common.ssh.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
-timeout
-- Returns:
- Throws:
ShellTimeoutException
com.sshtools.common.ssh.SshException
-
expect
public boolean expect(String pattern, boolean consumeRemainingLine, long timeout) throws ShellTimeoutException, com.sshtools.common.ssh.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:
ShellTimeoutException
com.sshtools.common.ssh.SshException
-
expectNextLine
public boolean expectNextLine(String pattern) throws ShellTimeoutException, com.sshtools.common.ssh.SshException Perform expect on the next line of output only- Parameters:
pattern
-- Returns:
- Throws:
ShellTimeoutException
com.sshtools.common.ssh.SshException
-
expectNextLine
public boolean expectNextLine(String pattern, boolean consumeRemainingLine) throws ShellTimeoutException, com.sshtools.common.ssh.SshException Perform expect on the next line of output only- Parameters:
pattern
-consumeRemainingLine
-- Returns:
- Throws:
ShellTimeoutException
com.sshtools.common.ssh.SshException
-
expectNextLine
public boolean expectNextLine(String pattern, boolean consumeRemainingLine, long timeout) throws ShellTimeoutException, com.sshtools.common.ssh.SshException Perform expect on the next line of output only- Parameters:
pattern
-consumeRemainingLine
-timeout
-- Returns:
- Throws:
ShellTimeoutException
com.sshtools.common.ssh.SshException
-
expect
public boolean expect(String pattern, boolean consumeRemainingLine, long timeout, long maxLines) throws ShellTimeoutException, com.sshtools.common.ssh.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:
ShellTimeoutException
com.sshtools.common.ssh.SshException
-
isEOF
public boolean isEOF() -
isActive
public boolean isActive() -
readLine
Description copied from interface:ShellReader
Read a line of output from the process.- Specified by:
readLine
in interfaceShellReader
- Returns:
- Throws:
com.sshtools.common.ssh.SshException
ShellTimeoutException
-
readLine
public String readLine(long timeout) throws com.sshtools.common.ssh.SshException, ShellTimeoutException Description copied from interface:ShellReader
Read a line of output from the process.- Specified by:
readLine
in interfaceShellReader
- Returns:
- Throws:
com.sshtools.common.ssh.SshException
ShellTimeoutException
-
getReadlimit
public int getReadlimit() -
setReadlimit
public void setReadlimit(int readlimit)
-