public class ShellController extends java.lang.Object implements ShellReader, ShellWriter
Modifier and Type | Field and Description |
---|---|
protected java.io.InputStream |
in |
protected ShellMatcher |
matcher |
protected int |
readlimit |
protected ExpectShell |
shell |
Modifier and Type | Method and Description |
---|---|
void |
carriageReturn()
Send a carriage return to the remote command.
|
boolean |
expect(java.lang.String pattern)
Consume the output of the command until the pattern matches.
|
boolean |
expect(java.lang.String pattern,
boolean consumeRemainingLine)
Consume the output of the command until the pattern matches.
|
boolean |
expect(java.lang.String pattern,
boolean consumeRemainingLine,
long timeout)
Consume the output of the command until the pattern matches.
|
boolean |
expect(java.lang.String pattern,
boolean consumeRemainingLine,
long timeout,
long maxLines)
Consume the output of the command until the pattern matches.
|
boolean |
expect(java.lang.String pattern,
long timeout)
Consume the output of the command until the pattern matches.
|
boolean |
expectNextLine(java.lang.String pattern)
Perform expect on the next line of output only
|
boolean |
expectNextLine(java.lang.String pattern,
boolean consumeRemainingLine)
Perform expect on the next line of output only
|
boolean |
expectNextLine(java.lang.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() |
java.lang.String |
readLine()
Read a line of output from the process.
|
java.lang.String |
readLine(long timeout)
Read a line of output from the process.
|
void |
setMatcher(ShellMatcher matcher) |
void |
setReadlimit(int readlimit) |
void |
type(java.lang.String string)
Send data to the remote command just like the user had typed it.
|
void |
typeAndReturn(java.lang.String string)
Send data to the remote command and finish with a carriage return.
|
protected ExpectShell shell
protected ShellMatcher matcher
protected int readlimit
protected java.io.InputStream in
public void setMatcher(ShellMatcher matcher)
public void interrupt() throws java.io.IOException
ShellWriter
interrupt
in interface ShellWriter
java.io.IOException
public void type(java.lang.String string) throws java.io.IOException
ShellWriter
type
in interface ShellWriter
string
- the typed key datajava.io.IOException
public void carriageReturn() throws java.io.IOException
ShellWriter
carriageReturn
in interface ShellWriter
java.io.IOException
public void typeAndReturn(java.lang.String string) throws java.io.IOException
ShellWriter
typeAndReturn
in interface ShellWriter
string
- Stringjava.io.IOException
public boolean expect(java.lang.String pattern) throws ShellTimeoutException, com.sshtools.common.ssh.SshException
pattern
- ShellTimeoutException
com.sshtools.common.ssh.SshException
public boolean expect(java.lang.String pattern, boolean consumeRemainingLine) throws ShellTimeoutException, com.sshtools.common.ssh.SshException
pattern
- consumeRemainingLine
- ShellTimeoutException
com.sshtools.common.ssh.SshException
public boolean expect(java.lang.String pattern, long timeout) throws ShellTimeoutException, com.sshtools.common.ssh.SshException
pattern
- timeout
- ShellTimeoutException
com.sshtools.common.ssh.SshException
public boolean expect(java.lang.String pattern, boolean consumeRemainingLine, long timeout) throws ShellTimeoutException, com.sshtools.common.ssh.SshException
pattern
- consumeRemainingLine
- timeout
- maxLines
- ShellTimeoutException
com.sshtools.common.ssh.SshException
public boolean expectNextLine(java.lang.String pattern) throws ShellTimeoutException, com.sshtools.common.ssh.SshException
pattern
- ShellTimeoutException
com.sshtools.common.ssh.SshException
public boolean expectNextLine(java.lang.String pattern, boolean consumeRemainingLine) throws ShellTimeoutException, com.sshtools.common.ssh.SshException
pattern
- consumeRemainingLine
- ShellTimeoutException
com.sshtools.common.ssh.SshException
public boolean expectNextLine(java.lang.String pattern, boolean consumeRemainingLine, long timeout) throws ShellTimeoutException, com.sshtools.common.ssh.SshException
pattern
- consumeRemainingLine
- timeout
- ShellTimeoutException
com.sshtools.common.ssh.SshException
public boolean expect(java.lang.String pattern, boolean consumeRemainingLine, long timeout, long maxLines) throws ShellTimeoutException, com.sshtools.common.ssh.SshException
pattern
- consumeRemainingLine
- timeout
- maxLines
- ShellTimeoutException
com.sshtools.common.ssh.SshException
public boolean isActive()
public java.lang.String readLine() throws com.sshtools.common.ssh.SshException, ShellTimeoutException
ShellReader
readLine
in interface ShellReader
com.sshtools.common.ssh.SshException
ShellTimeoutException
public java.lang.String readLine(long timeout) throws com.sshtools.common.ssh.SshException, ShellTimeoutException
ShellReader
readLine
in interface ShellReader
com.sshtools.common.ssh.SshException
ShellTimeoutException
public int getReadlimit()
public void setReadlimit(int readlimit)
Copyright © 2024. All rights reserved.