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 String
static final int
static final int
static final String
private static final AtomicReference<String>
private static final AtomicReference<String>
private static final AtomicLong
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static int
copyStream
(InputStream in, OutputStream bout) static String
Execute the specified command and return the output (both stdout and stderr).private static String
Execute the specified command and return the output (both stdout and stderr).private static int
private static int
static String
static int
Returns the value of "stty size" height param.static int
getTerminalProperty
(String prop) static int
Returns the value of "stty size" width param.static String
parsePtyModes
(String stty) static void
setSttyCommand
(String cmd) static String
Execute 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:
IOException
InterruptedException
-
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:
IOException
InterruptedException
-
getTtyProps
- Throws:
IOException
InterruptedException
-
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_PROP
system property if not set via this method
-