Package org.apache.sshd.common.channel
Class SttySupport
java.lang.Object
org.apache.sshd.common.channel.SttySupport
Support for stty command on unix
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final intstatic final intstatic final Stringprivate static final AtomicReference<String> private static final AtomicReference<String> private static final AtomicLong -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static intcopyStream(InputStream in, OutputStream bout) static StringExecute the specified command and return the output (both stdout and stderr).private static StringExecute the specified command and return the output (both stdout and stderr).private static intprivate static intstatic Stringstatic intReturns the value of "stty size" height param.static intgetTerminalProperty(String prop) static intReturns the value of "stty size" width param.static StringparsePtyModes(String stty) static voidsetSttyCommand(String cmd) static StringExecute the stty command with the specified arguments against the current active terminal.
-
Field Details
-
DEFAULT_TERMINAL_WIDTH
public static final int DEFAULT_TERMINAL_WIDTH- See Also:
-
DEFAULT_TERMINAL_HEIGHT
public static final int DEFAULT_TERMINAL_HEIGHT- See Also:
-
SSHD_STTY_COMMAND_PROP
- See Also:
-
DEFAULT_SSHD_STTY_COMMAND
- See Also:
-
STTY_COMMAND_HOLDER
-
TTY_PROPS_HOLDER
-
TTY_PROPS_LAST_FETCHED_HOLDER
-
-
Constructor Details
-
SttySupport
private SttySupport()
-
-
Method Details
-
getUnixPtyModes
- Throws:
IOExceptionInterruptedException
-
parsePtyModes
-
findFlag
-
findChar
-
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
- Throws:
IOExceptionInterruptedException
-
getTtyProps
- Throws:
IOExceptionInterruptedException
-
stty
Execute the stty command with the specified arguments against the current active terminal.- Parameters:
args- The command arguments- Returns:
- The execution result
- Throws:
IOException- If failed to execute the commandInterruptedException- If interrupted while awaiting command execution- See Also:
-
exec
Execute the specified command and return the output (both stdout and stderr).- Parameters:
cmd- The command to execute- Returns:
- The execution result
- Throws:
IOException- If failed to execute the commandInterruptedException- If interrupted while awaiting command execution- See Also:
-
exec
Execute the specified command and return the output (both stdout and stderr).- Parameters:
cmd- The command components- Returns:
- The execution result
- Throws:
IOException- If failed to execute the commandInterruptedException- If interrupted while awaiting command execution
-
copyStream
- Throws:
IOException
-
getSttyCommand
- Returns:
- The command to use to set the terminal options.
- See Also:
-
setSttyCommand
- 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
-