Package com.sshtools.client.shell
Class ExpectShell
java.lang.Object
com.sshtools.client.shell.ExpectShell
Execute commands within a shell, capturing the output of just the command
itself.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder that creates anExpectShell.static enumEnumeration of operating systems, that also encapsulates some operating specific information -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intDeprecated, for removal: This API element is subject to removal in a future version.static final intDeprecated, for removal: This API element is subject to removal in a future version.static final intDeprecated, for removal: This API element is subject to removal in a future version.static final intDeprecated, for removal: This API element is subject to removal in a future version.static final intDeprecated, for removal: This API element is subject to removal in a future version.static final intDeprecated, for removal: This API element is subject to removal in a future version.static final intDeprecated, for removal: This API element is subject to removal in a future version.static final intDeprecated, for removal: This API element is subject to removal in a future version.static final intDeprecated, for removal: This API element is subject to removal in a future version.static final intDeprecated, for removal: This API element is subject to removal in a future version.static final intDeprecated, for removal: This API element is subject to removal in a future version.static final intDeprecated, for removal: This API element is subject to removal in a future version.static final intDeprecated, for removal: This API element is subject to removal in a future version. -
Constructor Summary
ConstructorsConstructorDescriptionExpectShell(SessionChannelNG session, int osType) Deprecated, for removal: This API element is subject to removal in a future version.ExpectShell(SessionChannelNG session, ShellStartupTrigger trigger, long startupTimeout, ExpectShell.OS osType) Deprecated, for removal: This API element is subject to removal in a future version.ExpectShell(AbstractSessionTask<SessionChannelNG> session) Deprecated, for removal: This API element is subject to removal in a future version.ExpectShell(AbstractSessionTask<SessionChannelNG> session, int osType) Deprecated, for removal: This API element is subject to removal in a future version.ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger) Deprecated, for removal: This API element is subject to removal in a future version.ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger, long startupTimeout) Deprecated, for removal: This API element is subject to removal in a future version.ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger, long startupTimeout, int osType) Deprecated, for removal: This API element is subject to removal in a future version.ExpectShell(InputStream in, OutputStream out, ExpectShell parentShell) Deprecated, for removal: This API element is subject to removal in a future version.ExpectShell(InputStream in, OutputStream out, ExpectShell parentShell, ExpectShell.OS osType) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidexecuteCommand(String origCmd) executeCommand(String origCmd, boolean consume) executeCommand(String origCmd, boolean matchPromptMarker, boolean consume) executeCommand(String origCmd, boolean matchPromptMarker, boolean consume, String charsetName) executeCommand(String origCmd, boolean consume, String charset) executeCommand(String origCmd, String charset) intexecuteWithOutput(String cmd) voidexit()Deprecated, for removal: This API element is subject to removal in a future version.intintbooleanbooleanisClosed()voidsetCharacterEncoding(String characterEncoding) Deprecated, for removal: This API element is subject to removal in a future version.voidsetPasswordErrorText(String passwordErrorText) Deprecated, for removal: This API element is subject to removal in a future version.voidsetPasswordPrompt(String passwordPrompt) Deprecated, for removal: This API element is subject to removal in a future version.static voidsetShellInitTimeout(int timeout) Deprecated, for removal: This API element is subject to removal in a future version.voidsetSudoPassword(Optional<String> sudoPassword) su(String cmd, String password, String passwordPrompt, ShellMatcher matcher) sudo(String cmd, String password, String promptExpression, ShellMatcher matcher)
-
Field Details
-
OS_WINDOWS
Deprecated, for removal: This API element is subject to removal in a future version.Windows operating system- See Also:
-
OS_LINUX
Deprecated, for removal: This API element is subject to removal in a future version.Linux operating system- See Also:
-
OS_SOLARIS
Deprecated, for removal: This API element is subject to removal in a future version.Solaris operating system- See Also:
-
OS_AIX
Deprecated, for removal: This API element is subject to removal in a future version.AIX operating system- See Also:
-
OS_DARWIN
Deprecated, for removal: This API element is subject to removal in a future version.Darwin (MAC) operating system- See Also:
-
OS_FREEBSD
Deprecated, for removal: This API element is subject to removal in a future version.FreeBSD operating system- See Also:
-
OS_OPENBSD
Deprecated, for removal: This API element is subject to removal in a future version.OpenBSD operating system- See Also:
-
OS_NETBSD
Deprecated, for removal: This API element is subject to removal in a future version.NetBSD operating system- See Also:
-
OS_HPUX
Deprecated, for removal: This API element is subject to removal in a future version.HP-UX operating system- See Also:
-
OS_UNIX
Deprecated, for removal: This API element is subject to removal in a future version.Unix OS if less than this value.- See Also:
-
OS_OPENVMS
Deprecated, for removal: This API element is subject to removal in a future version.OpenVMS operating system- See Also:
-
OS_POWERSHELL
Deprecated, for removal: This API element is subject to removal in a future version.Linux operating system- See Also:
-
OS_UNKNOWN
Deprecated, for removal: This API element is subject to removal in a future version.The operating system is unknown- See Also:
-
EXIT_CODE_PROCESS_ACTIVE
public static final int EXIT_CODE_PROCESS_ACTIVE- See Also:
-
EXIT_CODE_UNKNOWN
public static final int EXIT_CODE_UNKNOWN- See Also:
-
-
Constructor Details
-
ExpectShell
@Deprecated(since="3.2.0", forRemoval=true) public ExpectShell(AbstractSessionTask<SessionChannelNG> session) throws SshException, IOException, ShellTimeoutException Deprecated, for removal: This API element is subject to removal in a future version. -
ExpectShell
@Deprecated(since="3.2.0", forRemoval=true) public ExpectShell(AbstractSessionTask<SessionChannelNG> session, int osType) throws SshException, IOException, ShellTimeoutException Deprecated, for removal: This API element is subject to removal in a future version. -
ExpectShell
@Deprecated(since="3.2.0", forRemoval=true) public ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger) throws SshException, IOException, ShellTimeoutException Deprecated, for removal: This API element is subject to removal in a future version. -
ExpectShell
@Deprecated(since="3.2.0", forRemoval=true) public ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger, long startupTimeout) throws SshException, IOException, ShellTimeoutException Deprecated, for removal: This API element is subject to removal in a future version. -
ExpectShell
@Deprecated(forRemoval=true) public ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger, long startupTimeout, int osType) throws SshException, IOException, ShellTimeoutException Deprecated, for removal: This API element is subject to removal in a future version. -
ExpectShell
@Deprecated(since="3.2.0", forRemoval=true) public ExpectShell(SessionChannelNG session, int osType) throws SshException, IOException, ShellTimeoutException Deprecated, for removal: This API element is subject to removal in a future version. -
ExpectShell
@Deprecated(since="3.2.0", forRemoval=true) public ExpectShell(SessionChannelNG session, ShellStartupTrigger trigger, long startupTimeout, ExpectShell.OS osType) throws SshException, IOException, ShellTimeoutException Deprecated, for removal: This API element is subject to removal in a future version. -
ExpectShell
@Deprecated(since="3.2.0", forRemoval=true) public ExpectShell(InputStream in, OutputStream out, ExpectShell parentShell) throws SshIOException, SshException, IOException, ShellTimeoutException Deprecated, for removal: This API element is subject to removal in a future version. -
ExpectShell
@Deprecated(since="3.2.0") public ExpectShell(InputStream in, OutputStream out, ExpectShell parentShell, ExpectShell.OS osType) throws SshIOException, SshException, IOException, ShellTimeoutException Deprecated.Deprecated. Will be made private at 3.3.0.- Parameters:
in- inout- outparentShell- parentShellosType- os type- Throws:
SshIOException- on SSH IO errorSshException- on SSH errrorIOException- on IO errorShellTimeoutException- on timeout
-
-
Method Details
-
getCharacterEncoding
Deprecated, for removal: This API element is subject to removal in a future version. -
setCharacterEncoding
@Deprecated(since="3.2.0", forRemoval=true) public void setCharacterEncoding(String characterEncoding) Deprecated, for removal: This API element is subject to removal in a future version.Set the default character encoding.Deprecated for removal. Character encoding will become final, use the builder option instead.
- Parameters:
characterEncoding- character encoding.
-
setShellInitTimeout
Deprecated, for removal: This API element is subject to removal in a future version. -
getStartupInputStream
-
inStartup
public boolean inStartup() -
setPasswordErrorText
@Deprecated(since="3.2.0", forRemoval=true) public void setPasswordErrorText(String passwordErrorText) Deprecated, for removal: This API element is subject to removal in a future version.Set the password error text string.Deprecated for removal. Password error text will become final, use the builder option instead.
- Parameters:
passwordErrorText- password error text
-
setPasswordPrompt
Deprecated, for removal: This API element is subject to removal in a future version.Set the password prompt string.Deprecated for removal. Password prompt will become final, use the builder option instead.
- Parameters:
passwordPrompt- password prompt
-
getStartupReader
-
su
public ExpectShell su(String cmd, String password) throws SshIOException, SshException, IOException, ShellTimeoutException -
su
public ExpectShell su(String cmd, String password, String passwordPrompt) throws SshException, SshIOException, IOException, ShellTimeoutException -
su
public ExpectShell su(String cmd) throws SshException, SshIOException, IOException, ShellTimeoutException -
su
public ExpectShell su(String cmd, String password, String passwordPrompt, ShellMatcher matcher) throws SshException, SshIOException, IOException, ShellTimeoutException -
sudo
public ShellProcess sudo(String cmd, String password) throws SshException, ShellTimeoutException, IOException -
sudo
-
sudo
public ShellProcess sudo(String cmd, String password, String promptExpression) throws SshException, ShellTimeoutException, IOException -
sudo
public ShellProcess sudo(String cmd, String password, String promptExpression, ShellMatcher matcher) throws SshException, ShellTimeoutException, IOException -
isClosed
public boolean isClosed() -
exit
- Throws:
IOExceptionSshException
-
close
- Throws:
IOExceptionSshException
-
getNewline
-
executeWithOutput
- Throws:
SshException
-
executeWithExitCode
- Throws:
SshException
-
execute
- Throws:
SshException
-
executeCommand
- Throws:
SshException
-
executeCommand
- Throws:
SshException
-
executeCommand
- Throws:
SshException
-
executeCommand
public ShellProcess executeCommand(String origCmd, boolean consume, String charset) throws SshException - Throws:
SshException
-
executeCommand
public ShellProcess executeCommand(String origCmd, boolean matchPromptMarker, boolean consume) throws SshException - Throws:
SshException
-
executeCommand
public ShellProcess executeCommand(String origCmd, boolean matchPromptMarker, boolean consume, String charsetName) throws SshException - Throws:
SshException
-
getNumCommandsExecuted
public int getNumCommandsExecuted() -
getOsType
public int getOsType() -
getOsDescription
-
setSudoPassword
-