Package com.sshtools.client.shell
Class ExpectShell
java.lang.Object
com.sshtools.client.shell.ExpectShell
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intAIX operating systemstatic final intDarwin (MAC) operating systemstatic final intFreeBSD operating systemstatic final intHP-UX operating systemstatic final intLinux operating systemstatic final intNetBSD operating systemstatic final intOpenBSD operating systemstatic final intOpenVMS operating systemstatic final intLinux operating systemstatic final intSolaris operating systemstatic final intUnix OS if less than this value.static final intThe operating system is unknownstatic final intWindows operating system -
Constructor Summary
ConstructorsConstructorDescriptionExpectShell(SessionChannelNG session, int osType) ExpectShell(SessionChannelNG session, ShellStartupTrigger trigger, long startupTimeout, String termtype, int cols, int rows, int osType) ExpectShell(AbstractSessionTask<SessionChannelNG> session) ExpectShell(AbstractSessionTask<SessionChannelNG> session, int osType) ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger) ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger, long startupTimeout) ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger, long startupTimeout, String termtype) Deprecated.ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger, long startupTimeout, String termtype, int cols, int rows) Deprecated.ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger, long startupTimeout, String termtype, int cols, int rows, int osType) Deprecated.ExpectShell(InputStream in, OutputStream out, ExpectShell parentShell) ExpectShell(InputStream in, OutputStream out, ExpectShell parentShell, int osType) -
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 charset) executeCommand(String origCmd, boolean consume, String charset) executeCommand(String origCmd, String charset) intexecuteWithOutput(String cmd) voidexit()intintbooleanbooleanisClosed()voidsetCharacterEncoding(String characterEncoding) voidsetPasswordErrorText(String passwordErrorText) voidsetPasswordPrompt(String passwordPrompt) static voidsetShellInitTimeout(int timeout) su(String cmd, String password, String promptExpression, ShellMatcher matcher) sudo(String cmd, String password, String promptExpression, ShellMatcher matcher)
-
Field Details
-
OS_WINDOWS
public static final int OS_WINDOWSWindows operating system- See Also:
-
OS_LINUX
public static final int OS_LINUXLinux operating system- See Also:
-
OS_SOLARIS
public static final int OS_SOLARISSolaris operating system- See Also:
-
OS_AIX
public static final int OS_AIXAIX operating system- See Also:
-
OS_DARWIN
public static final int OS_DARWINDarwin (MAC) operating system- See Also:
-
OS_FREEBSD
public static final int OS_FREEBSDFreeBSD operating system- See Also:
-
OS_OPENBSD
public static final int OS_OPENBSDOpenBSD operating system- See Also:
-
OS_NETBSD
public static final int OS_NETBSDNetBSD operating system- See Also:
-
OS_HPUX
public static final int OS_HPUXHP-UX operating system- See Also:
-
OS_UNIX
public static final int OS_UNIXUnix OS if less than this value.- See Also:
-
OS_OPENVMS
public static final int OS_OPENVMSOpenVMS operating system- See Also:
-
OS_POWERSHELL
public static final int OS_POWERSHELLLinux operating system- See Also:
-
OS_UNKNOWN
public static final int OS_UNKNOWNThe 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
public ExpectShell(AbstractSessionTask<SessionChannelNG> session) throws SshException, IOException, ShellTimeoutException -
ExpectShell
public ExpectShell(AbstractSessionTask<SessionChannelNG> session, int osType) throws SshException, IOException, ShellTimeoutException -
ExpectShell
public ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger) throws SshException, IOException, ShellTimeoutException -
ExpectShell
public ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger, long startupTimeout) throws SshException, IOException, ShellTimeoutException -
ExpectShell
@Deprecated public ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger, long startupTimeout, String termtype) throws SshException, IOException, ShellTimeoutException Deprecated. -
ExpectShell
@Deprecated public ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger, long startupTimeout, String termtype, int cols, int rows) throws SshException, IOException, ShellTimeoutException Deprecated. -
ExpectShell
@Deprecated public ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger, long startupTimeout, String termtype, int cols, int rows, int osType) throws SshException, IOException, ShellTimeoutException Deprecated. -
ExpectShell
public ExpectShell(SessionChannelNG session, int osType) throws SshException, IOException, ShellTimeoutException -
ExpectShell
public ExpectShell(SessionChannelNG session, ShellStartupTrigger trigger, long startupTimeout, String termtype, int cols, int rows, int osType) throws SshException, IOException, ShellTimeoutException -
ExpectShell
public ExpectShell(InputStream in, OutputStream out, ExpectShell parentShell) throws SshIOException, SshException, IOException, ShellTimeoutException -
ExpectShell
public ExpectShell(InputStream in, OutputStream out, ExpectShell parentShell, int osType) throws SshIOException, SshException, IOException, ShellTimeoutException
-
-
Method Details
-
getCharacterEncoding
-
setCharacterEncoding
-
setShellInitTimeout
public static void setShellInitTimeout(int timeout) -
getStartupInputStream
-
inStartup
public boolean inStartup() -
setPasswordErrorText
-
setPasswordPrompt
-
getStartupReader
-
su
public ExpectShell su(String cmd, String password) throws SshIOException, SshException, IOException, ShellTimeoutException -
su
public ExpectShell su(String cmd, String password, String promptExpression) 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 promptExpression, ShellMatcher matcher) throws SshException, SshIOException, IOException, ShellTimeoutException -
sudo
public ShellProcess sudo(String cmd, String password) throws SshException, ShellTimeoutException, IOException -
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 charset) throws SshException - Throws:
SshException
-
getNumCommandsExecuted
public int getNumCommandsExecuted() -
getOsType
public int getOsType() -
getOsDescription
-