Package com.sshtools.client.shell
Class ExpectShell
java.lang.Object
com.sshtools.client.shell.ExpectShell
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
AIX operating systemstatic final int
Darwin (MAC) operating systemstatic final int
FreeBSD operating systemstatic final int
HP-UX operating systemstatic final int
Linux operating systemstatic final int
NetBSD operating systemstatic final int
OpenBSD operating systemstatic final int
OpenVMS operating systemstatic final int
Linux operating systemstatic final int
Solaris operating systemstatic final int
Unix OS if less than this value.static final int
The operating system is unknownstatic final int
Windows operating system -
Constructor Summary
ConstructorsConstructorDescriptionExpectShell
(AbstractSessionTask<SessionChannelNG> session) ExpectShell
(AbstractSessionTask<SessionChannelNG> task, 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
(InputStream in, OutputStream out, ExpectShell parentShell) ExpectShell
(InputStream in, OutputStream out, ExpectShell parentShell, int osType) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
executeCommand
(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) int
executeWithOutput
(String cmd) void
exit()
int
int
boolean
boolean
isClosed()
void
setCharacterEncoding
(String characterEncoding) void
setPasswordErrorText
(String passwordErrorText) void
setPasswordPrompt
(String passwordPrompt) static void
setShellInitTimeout
(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 com.sshtools.common.ssh.SshException, IOException, ShellTimeoutException - Throws:
com.sshtools.common.ssh.SshException
IOException
ShellTimeoutException
-
ExpectShell
public ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger) throws com.sshtools.common.ssh.SshException, IOException, ShellTimeoutException - Throws:
com.sshtools.common.ssh.SshException
IOException
ShellTimeoutException
-
ExpectShell
public ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger, long startupTimeout) throws com.sshtools.common.ssh.SshException, IOException, ShellTimeoutException - Throws:
com.sshtools.common.ssh.SshException
IOException
ShellTimeoutException
-
ExpectShell
@Deprecated public ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger, long startupTimeout, String termtype) throws com.sshtools.common.ssh.SshException, IOException, ShellTimeoutException Deprecated.- Throws:
com.sshtools.common.ssh.SshException
IOException
ShellTimeoutException
-
ExpectShell
@Deprecated public ExpectShell(AbstractSessionTask<SessionChannelNG> session, ShellStartupTrigger trigger, long startupTimeout, String termtype, int cols, int rows) throws com.sshtools.common.ssh.SshException, IOException, ShellTimeoutException Deprecated.- Throws:
com.sshtools.common.ssh.SshException
IOException
ShellTimeoutException
-
ExpectShell
public ExpectShell(InputStream in, OutputStream out, ExpectShell parentShell) throws com.sshtools.common.ssh.SshIOException, com.sshtools.common.ssh.SshException, IOException, ShellTimeoutException - Throws:
com.sshtools.common.ssh.SshIOException
com.sshtools.common.ssh.SshException
IOException
ShellTimeoutException
-
ExpectShell
public ExpectShell(InputStream in, OutputStream out, ExpectShell parentShell, int osType) throws com.sshtools.common.ssh.SshIOException, com.sshtools.common.ssh.SshException, IOException, ShellTimeoutException - Throws:
com.sshtools.common.ssh.SshIOException
com.sshtools.common.ssh.SshException
IOException
ShellTimeoutException
-
ExpectShell
public ExpectShell(AbstractSessionTask<SessionChannelNG> task, int osType) throws com.sshtools.common.ssh.SshIOException, com.sshtools.common.ssh.SshException, IOException, ShellTimeoutException - Throws:
com.sshtools.common.ssh.SshIOException
com.sshtools.common.ssh.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 com.sshtools.common.ssh.SshIOException, com.sshtools.common.ssh.SshException, IOException, ShellTimeoutException - Throws:
com.sshtools.common.ssh.SshIOException
com.sshtools.common.ssh.SshException
IOException
ShellTimeoutException
-
su
public ExpectShell su(String cmd, String password, String promptExpression) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.SshIOException, IOException, ShellTimeoutException - Throws:
com.sshtools.common.ssh.SshException
com.sshtools.common.ssh.SshIOException
IOException
ShellTimeoutException
-
su
public ExpectShell su(String cmd) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.SshIOException, IOException, ShellTimeoutException - Throws:
com.sshtools.common.ssh.SshException
com.sshtools.common.ssh.SshIOException
IOException
ShellTimeoutException
-
su
public ExpectShell su(String cmd, String password, String promptExpression, ShellMatcher matcher) throws com.sshtools.common.ssh.SshException, com.sshtools.common.ssh.SshIOException, IOException, ShellTimeoutException - Throws:
com.sshtools.common.ssh.SshException
com.sshtools.common.ssh.SshIOException
IOException
ShellTimeoutException
-
sudo
public ShellProcess sudo(String cmd, String password) throws com.sshtools.common.ssh.SshException, ShellTimeoutException, IOException - Throws:
com.sshtools.common.ssh.SshException
ShellTimeoutException
IOException
-
sudo
public ShellProcess sudo(String cmd, String password, String promptExpression) throws com.sshtools.common.ssh.SshException, ShellTimeoutException, IOException - Throws:
com.sshtools.common.ssh.SshException
ShellTimeoutException
IOException
-
sudo
public ShellProcess sudo(String cmd, String password, String promptExpression, ShellMatcher matcher) throws com.sshtools.common.ssh.SshException, ShellTimeoutException, IOException - Throws:
com.sshtools.common.ssh.SshException
ShellTimeoutException
IOException
-
isClosed
public boolean isClosed() -
exit
- Throws:
IOException
com.sshtools.common.ssh.SshException
-
close
- Throws:
IOException
com.sshtools.common.ssh.SshException
-
getNewline
-
executeWithOutput
- Throws:
com.sshtools.common.ssh.SshException
-
executeWithExitCode
- Throws:
com.sshtools.common.ssh.SshException
-
execute
- Throws:
com.sshtools.common.ssh.SshException
-
executeCommand
- Throws:
com.sshtools.common.ssh.SshException
-
executeCommand
public ShellProcess executeCommand(String origCmd, boolean consume) throws com.sshtools.common.ssh.SshException - Throws:
com.sshtools.common.ssh.SshException
-
executeCommand
public ShellProcess executeCommand(String origCmd, String charset) throws com.sshtools.common.ssh.SshException - Throws:
com.sshtools.common.ssh.SshException
-
executeCommand
public ShellProcess executeCommand(String origCmd, boolean consume, String charset) throws com.sshtools.common.ssh.SshException - Throws:
com.sshtools.common.ssh.SshException
-
executeCommand
public ShellProcess executeCommand(String origCmd, boolean matchPromptMarker, boolean consume) throws com.sshtools.common.ssh.SshException - Throws:
com.sshtools.common.ssh.SshException
-
executeCommand
public ShellProcess executeCommand(String origCmd, boolean matchPromptMarker, boolean consume, String charset) throws com.sshtools.common.ssh.SshException - Throws:
com.sshtools.common.ssh.SshException
-
getNumCommandsExecuted
public int getNumCommandsExecuted() -
getOsType
public int getOsType() -
getOsDescription
-