public class ShellController extends Object implements ShellReader, ShellWriter
Modifier and Type | Field and Description |
---|---|
protected InputStream |
in |
protected ShellMatcher |
matcher |
protected int |
readlimit |
protected Shell |
shell |
Modifier and Type | Method and Description |
---|---|
void |
carriageReturn()
Send a carriage return to the remote command.
|
boolean |
expect(String pattern)
Consume the output of the command until the pattern matches.
|
boolean |
expect(String pattern,
boolean consumeRemainingLine)
Consume the output of the command until the pattern matches.
|
boolean |
expect(String pattern,
boolean consumeRemainingLine,
long timeout)
Consume the output of the command until the pattern matches.
|
boolean |
expect(String pattern,
boolean consumeRemainingLine,
long timeout,
long maxLines)
Consume the output of the command until the pattern matches.
|
boolean |
expect(String pattern,
long timeout)
Consume the output of the command until the pattern matches.
|
boolean |
expectNextLine(String pattern)
Perform expect on the next line of output only
|
boolean |
expectNextLine(String pattern,
boolean consumeRemainingLine)
Perform expect on the next line of output only
|
boolean |
expectNextLine(String pattern,
boolean consumeRemainingLine,
long timeout)
Perform expect on the next line of output only
|
int |
getReadlimit() |
void |
interrupt()
Interrupt the process by sending a Ctrl+C to the process.
|
boolean |
isActive() |
String |
readLine()
Read a line of output from the process.
|
String |
readLine(long timeout)
Read a line of output from the process.
|
void |
setMatcher(ShellMatcher matcher) |
void |
setReadlimit(int readlimit) |
void |
type(String string)
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.
|
protected Shell shell
protected ShellMatcher matcher
protected int readlimit
protected InputStream in
public void setMatcher(ShellMatcher matcher)
public void interrupt() throws IOException
ShellWriter
interrupt
in interface ShellWriter
IOException
public void type(String string) throws IOException
ShellWriter
type
in interface ShellWriter
string
- the typed key dataIOException
public void carriageReturn() throws IOException
ShellWriter
carriageReturn
in interface ShellWriter
IOException
public void typeAndReturn(String string) throws IOException
ShellWriter
typeAndReturn
in interface ShellWriter
string
- StringIOException
public boolean expect(String pattern) throws ShellTimeoutException, SshException
pattern
- ShellTimeoutException
SshException
public boolean expect(String pattern, boolean consumeRemainingLine) throws ShellTimeoutException, SshException
pattern
- consumeRemainingLine
- ShellTimeoutException
SshException
public boolean expect(String pattern, long timeout) throws ShellTimeoutException, SshException
pattern
- timeout
- ShellTimeoutException
SshException
public boolean expect(String pattern, boolean consumeRemainingLine, long timeout) throws ShellTimeoutException, SshException
pattern
- consumeRemainingLine
- timeout
- maxLines
- ShellTimeoutException
SshException
public boolean expectNextLine(String pattern) throws ShellTimeoutException, SshException
pattern
- ShellTimeoutException
SshException
public boolean expectNextLine(String pattern, boolean consumeRemainingLine) throws ShellTimeoutException, SshException
pattern
- consumeRemainingLine
- ShellTimeoutException
SshException
public boolean expectNextLine(String pattern, boolean consumeRemainingLine, long timeout) throws ShellTimeoutException, SshException
pattern
- consumeRemainingLine
- timeout
- ShellTimeoutException
SshException
public boolean expect(String pattern, boolean consumeRemainingLine, long timeout, long maxLines) throws ShellTimeoutException, SshException
pattern
- consumeRemainingLine
- timeout
- maxLines
- ShellTimeoutException
SshException
public boolean isActive()
public String readLine() throws SshException, ShellTimeoutException
ShellReader
readLine
in interface ShellReader
SshException
ShellTimeoutException
public String readLine(long timeout) throws SshException, ShellTimeoutException
ShellReader
readLine
in interface ShellReader
SshException
ShellTimeoutException
public int getReadlimit()
public void setReadlimit(int readlimit)
Copyright © 2024. All rights reserved.