Package org.apache.sshd.common.channel
Class SttySupport
- java.lang.Object
-
- org.apache.sshd.common.channel.SttySupport
-
public final class SttySupport extends java.lang.ObjectSupport for stty command on unix
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_SSHD_STTY_COMMANDstatic intDEFAULT_TERMINAL_HEIGHTstatic intDEFAULT_TERMINAL_WIDTHstatic java.lang.StringSSHD_STTY_COMMAND_PROPprivate static java.util.concurrent.atomic.AtomicReference<java.lang.String>STTY_COMMAND_HOLDERprivate static java.util.concurrent.atomic.AtomicReference<java.lang.String>TTY_PROPS_HOLDERprivate static java.util.concurrent.atomic.AtomicLongTTY_PROPS_LAST_FETCHED_HOLDER
-
Constructor Summary
Constructors Modifier Constructor Description privateSttySupport()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static intcopyStream(java.io.InputStream in, java.io.OutputStream bout)static java.lang.Stringexec(java.lang.String cmd)Execute the specified command and return the output (both stdout and stderr).private static java.lang.Stringexec(java.lang.String... cmd)Execute the specified command and return the output (both stdout and stderr).private static intfindChar(java.lang.String stty, java.lang.String name)private static intfindFlag(java.lang.String stty, java.lang.String name)static java.lang.StringgetSttyCommand()static intgetTerminalHeight()Returns the value of "stty size" height param.static intgetTerminalProperty(java.lang.String prop)static intgetTerminalWidth()Returns the value of "stty size" width param.static java.lang.StringgetTtyProps()static java.util.Map<PtyMode,java.lang.Integer>getUnixPtyModes()static java.util.Map<PtyMode,java.lang.Integer>parsePtyModes(java.lang.String stty)static voidsetSttyCommand(java.lang.String cmd)static java.lang.Stringstty(java.lang.String args)Execute the stty command with the specified arguments against the current active terminal.
-
-
-
Field Detail
-
DEFAULT_TERMINAL_WIDTH
public static final int DEFAULT_TERMINAL_WIDTH
- See Also:
- Constant Field Values
-
DEFAULT_TERMINAL_HEIGHT
public static final int DEFAULT_TERMINAL_HEIGHT
- See Also:
- Constant Field Values
-
SSHD_STTY_COMMAND_PROP
public static final java.lang.String SSHD_STTY_COMMAND_PROP
- See Also:
- Constant Field Values
-
DEFAULT_SSHD_STTY_COMMAND
public static final java.lang.String DEFAULT_SSHD_STTY_COMMAND
- See Also:
- Constant Field Values
-
STTY_COMMAND_HOLDER
private static final java.util.concurrent.atomic.AtomicReference<java.lang.String> STTY_COMMAND_HOLDER
-
TTY_PROPS_HOLDER
private static final java.util.concurrent.atomic.AtomicReference<java.lang.String> TTY_PROPS_HOLDER
-
TTY_PROPS_LAST_FETCHED_HOLDER
private static final java.util.concurrent.atomic.AtomicLong TTY_PROPS_LAST_FETCHED_HOLDER
-
-
Method Detail
-
getUnixPtyModes
public static java.util.Map<PtyMode,java.lang.Integer> getUnixPtyModes() throws java.io.IOException, java.lang.InterruptedException
- Throws:
java.io.IOExceptionjava.lang.InterruptedException
-
parsePtyModes
public static java.util.Map<PtyMode,java.lang.Integer> parsePtyModes(java.lang.String stty)
-
findFlag
private static int findFlag(java.lang.String stty, java.lang.String name)
-
findChar
private static int findChar(java.lang.String stty, java.lang.String name)
-
getTerminalWidth
public static int getTerminalWidth()
Returns the value of "stty size" width param.
Note: this method caches the value from the first time it is called in order to increase speed, which means that changing to size of the terminal will not be reflected in the console.
- Returns:
- The terminal width
-
getTerminalHeight
public static int getTerminalHeight()
Returns the value of "stty size" height param.
Note: this method caches the value from the first time it is called in order to increase speed, which means that changing to size of the terminal will not be reflected in the console.
- Returns:
- The terminal height
-
getTerminalProperty
public static int getTerminalProperty(java.lang.String prop) throws java.io.IOException, java.lang.InterruptedException- Throws:
java.io.IOExceptionjava.lang.InterruptedException
-
getTtyProps
public static java.lang.String getTtyProps() throws java.io.IOException, java.lang.InterruptedException- Throws:
java.io.IOExceptionjava.lang.InterruptedException
-
stty
public static java.lang.String stty(java.lang.String args) throws java.io.IOException, java.lang.InterruptedExceptionExecute the stty command with the specified arguments against the current active terminal.- Parameters:
args- The command arguments- Returns:
- The execution result
- Throws:
java.io.IOException- If failed to execute the commandjava.lang.InterruptedException- If interrupted while awaiting command execution- See Also:
exec(String)
-
exec
public static java.lang.String exec(java.lang.String cmd) throws java.io.IOException, java.lang.InterruptedExceptionExecute the specified command and return the output (both stdout and stderr).- Parameters:
cmd- The command to execute- Returns:
- The execution result
- Throws:
java.io.IOException- If failed to execute the commandjava.lang.InterruptedException- If interrupted while awaiting command execution- See Also:
exec(String[])
-
exec
private static java.lang.String exec(java.lang.String... cmd) throws java.io.IOException, java.lang.InterruptedExceptionExecute the specified command and return the output (both stdout and stderr).- Parameters:
cmd- The command components- Returns:
- The execution result
- Throws:
java.io.IOException- If failed to execute the commandjava.lang.InterruptedException- If interrupted while awaiting command execution
-
copyStream
private static int copyStream(java.io.InputStream in, java.io.OutputStream bout) throws java.io.IOException- Throws:
java.io.IOException
-
getSttyCommand
public static java.lang.String getSttyCommand()
- Returns:
- The command to use to set the terminal options.
- See Also:
setSttyCommand(String)
-
setSttyCommand
public static void setSttyCommand(java.lang.String cmd)
- Parameters:
cmd- The command to use to set the terminal options. Defaults toDEFAULT_SSHD_STTY_COMMAND, or the value of theSSHD_STTY_COMMAND_PROPsystem property if not set via this method
-
-